Skip to content

Commit

Permalink
Merge pull request #160 from Crown-Commercial-Service/add-with-evalua…
Browse files Browse the repository at this point in the history
…tions-option

Add `with_evaluations` param to some routes
  • Loading branch information
tim-s-ccs authored Nov 29, 2024
2 parents ccac0d8 + a875d28 commit 0f8f212
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dmapiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '29.10.0'
__version__ = '29.11.0'

from .errors import APIError, HTTPError, InvalidResponse # noqa
from .errors import REQUEST_ERROR_STATUS_CODE, REQUEST_ERROR_MESSAGE # noqa
Expand Down
14 changes: 12 additions & 2 deletions dmapiclient/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@ def find_evaluator_framework_lots(
assigned=True,
locked=None,
with_sections=None,
with_evaluations=None,
page=None,
):
params = {
Expand All @@ -1696,6 +1697,7 @@ def find_evaluator_framework_lots(
'page': page,
'user_id': user_id,
'with_sections': with_sections,
'with_evaluations': with_evaluations,
'locked': locked,
}

Expand Down Expand Up @@ -1726,10 +1728,12 @@ def update_assigned_evaluators_for_framework_lot(
def get_evaluator_framework_lot(
self,
evaluator_framework_lot_id,
with_sections=True
with_sections=True,
with_evaluations=True,
):
params = {
'with_sections': bool(with_sections),
'with_evaluations': bool(with_evaluations),
}

return self._get(f"/evaluations/evaluator-framework-lots/{evaluator_framework_lot_id}", params=params)
Expand Down Expand Up @@ -1796,10 +1800,16 @@ def update_assigned_sections_for_evaluator_framework_lot(
def get_evaluator_framework_lot_section(
self,
evaluator_framework_lot_section_id,
with_evaluations=True,
):
params = {
'with_evaluations': bool(with_evaluations),
}

return self._get(
"/evaluations/evaluator-framework-lot-sections/"
f"{evaluator_framework_lot_section_id}"
f"{evaluator_framework_lot_section_id}",
params=params
)

def find_evaluator_framework_lot_section_evaluations(
Expand Down
40 changes: 37 additions & 3 deletions tests/test_data_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4424,9 +4424,21 @@ def test_find_evaluator_framework_lot_adds_with_sections_parameter(self, data_cl
assert result == {"evaluatorFrameworkLotSections": "result"}
assert rmock.called

def test_find_evaluator_framework_lot_adds_with_evaluations_parameter(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lots?"
"framework=g-cloud-6&lot=g-things&assigned=True&with_evaluations=True",
json={"evaluatorFrameworkLotSections": "result"},
status_code=200)

result = data_client.find_evaluator_framework_lots('g-cloud-6', 'g-things', with_evaluations=True)

assert result == {"evaluatorFrameworkLotSections": "result"}
assert rmock.called

def test_get_evaluator_framework_lot(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lots/1234?with_sections=True",
"http://baseurl/evaluations/evaluator-framework-lots/1234?with_sections=True&with_evaluations=True",
json={"evaluatorFrameworkLots": "result"},
status_code=200)

Expand All @@ -4437,7 +4449,7 @@ def test_get_evaluator_framework_lot(self, data_client, rmock):

def test_get_evaluator_framework_lot_adds_with_sections_parameter(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lots/1234?with_sections=False",
"http://baseurl/evaluations/evaluator-framework-lots/1234?with_sections=False&with_evaluations=True",
json={"evaluatorFrameworkLots": "result"},
status_code=200)

Expand All @@ -4446,6 +4458,17 @@ def test_get_evaluator_framework_lot_adds_with_sections_parameter(self, data_cli
assert result == {"evaluatorFrameworkLots": "result"}
assert rmock.called

def test_get_evaluator_framework_lot_adds_with_evaluations_parameter(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lots/1234?with_sections=True&with_evaluations=False",
json={"evaluatorFrameworkLots": "result"},
status_code=200)

result = data_client.get_evaluator_framework_lot(1234, with_evaluations=False)

assert result == {"evaluatorFrameworkLots": "result"}
assert rmock.called

def test_update_assigned_evaluators_for_framework_lot(self, data_client, rmock):
rmock.post(
"http://baseurl/evaluations/evaluator-framework-lots",
Expand Down Expand Up @@ -4591,7 +4614,7 @@ def test_update_assigned_sections_for_evaluator_framework_lot(self, data_client,

def test_get_evaluator_framework_lot_section(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lot-sections/1234",
"http://baseurl/evaluations/evaluator-framework-lot-sections/1234?with_evaluations=True",
json={"evaluatorFrameworkLotSections": "result"},
status_code=200)

Expand All @@ -4600,6 +4623,17 @@ def test_get_evaluator_framework_lot_section(self, data_client, rmock):
assert result == {"evaluatorFrameworkLotSections": "result"}
assert rmock.called

def test_get_evaluator_framework_lot_section_adds_with_evaluations_parameter(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lot-sections/1234?with_evaluations=False",
json={"evaluatorFrameworkLotSections": "result"},
status_code=200)

result = data_client.get_evaluator_framework_lot_section(1234, with_evaluations=False)

assert result == {"evaluatorFrameworkLotSections": "result"}
assert rmock.called

def test_find_evaluator_framework_lot_section_evaluations(self, data_client, rmock):
rmock.get(
"http://baseurl/evaluations/evaluator-framework-lot-section-evaluations?"
Expand Down

0 comments on commit 0f8f212

Please sign in to comment.