-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
LTD-5673: Productionise goods ratings endpoint
- Loading branch information
Showing
8 changed files
with
140 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
api/data_workspace/v2/tests/bdd/scenarios/goods_ratings.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@db | ||
Feature: goods_ratings Table | ||
|
||
Scenario: Draft application | ||
Given a draft standard application | ||
Then the `goods_ratings` table is empty | ||
|
||
Scenario: Submitted application | ||
Given a draft standard application | ||
And the application has the following goods: | ||
| id | name | | ||
| 8fa8dc3c-c103-42f5-ba94-2d9098b8821d | A controlled good | | ||
| 4dad5dc6-38ef-4bf7-99fd-0c6bc5d86048 | An NLR good | | ||
When the application is submitted | ||
Then the `goods_ratings` table is empty | ||
|
||
Scenario: Assess application | ||
Given a draft standard application | ||
And the application has the following goods: | ||
| id | name | | ||
| 8fa8dc3c-c103-42f5-ba94-2d9098b8821d | A controlled good | | ||
| 118a003c-7191-4a2c-97e9-be243722cbb2 | Another controlled good | | ||
| 4dad5dc6-38ef-4bf7-99fd-0c6bc5d86048 | An NLR good | | ||
When the application is submitted | ||
And the goods are assessed by TAU as: | ||
| id | Control list entry | Report summary prefix | Report summary subject | | ||
| 8fa8dc3c-c103-42f5-ba94-2d9098b8821d | ML22a | accessories for | composite laminates | | ||
| 118a003c-7191-4a2c-97e9-be243722cbb2 | PL9010 | | composite laminates | | ||
| 4dad5dc6-38ef-4bf7-99fd-0c6bc5d86048 | NLR | | | | ||
Then the `goods_ratings` table has the following rows: | ||
| good_id | rating | | ||
| 8fa8dc3c-c103-42f5-ba94-2d9098b8821d | ML22a | | ||
| 118a003c-7191-4a2c-97e9-be243722cbb2 | PL9010 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,4 @@ | ||
from pytest_bdd import ( | ||
given, | ||
parsers, | ||
scenarios, | ||
when, | ||
) | ||
|
||
from django.urls import reverse | ||
|
||
from api.applications.tests.factories import GoodOnApplicationFactory | ||
from api.staticdata.report_summaries.models import ( | ||
ReportSummaryPrefix, | ||
ReportSummarySubject, | ||
) | ||
from pytest_bdd import scenarios | ||
|
||
|
||
scenarios("./scenarios/goods_descriptions.feature") | ||
|
||
|
||
@given(parsers.parse("the application has the following goods:{goods}")) | ||
def given_the_application_has_the_following_goods(parse_table, draft_standard_application, goods): | ||
draft_standard_application.goods.all().delete() | ||
good_attributes = parse_table(goods)[1:] | ||
for id, name in good_attributes: | ||
GoodOnApplicationFactory( | ||
application=draft_standard_application, | ||
id=id, | ||
good__name=name, | ||
) | ||
|
||
|
||
@when(parsers.parse("the goods are assessed by TAU as:{assessments}")) | ||
def when_the_goods_are_assessed_by_tau( | ||
parse_table, | ||
submitted_standard_application, | ||
assessments, | ||
api_client, | ||
lu_case_officer, | ||
gov_headers, | ||
): | ||
assessments = parse_table(assessments)[1:] | ||
url = reverse("assessments:make_assessments", kwargs={"case_pk": submitted_standard_application.pk}) | ||
|
||
assessment_payload = [] | ||
for good_on_application_id, control_list_entry, report_summary_prefix, report_summary_subject in assessments: | ||
data = { | ||
"id": good_on_application_id, | ||
"comment": "Some comment", | ||
} | ||
|
||
if control_list_entry == "NLR": | ||
data.update( | ||
{ | ||
"control_list_entries": [], | ||
"is_good_controlled": False, | ||
} | ||
) | ||
else: | ||
if report_summary_prefix: | ||
prefix = ReportSummaryPrefix.objects.get(name=report_summary_prefix) | ||
else: | ||
prefix = None | ||
subject = ReportSummarySubject.objects.get(name=report_summary_subject) | ||
data.update( | ||
{ | ||
"control_list_entries": [control_list_entry], | ||
"report_summary_prefix": prefix.pk if prefix else None, | ||
"report_summary_subject": subject.pk, | ||
"is_good_controlled": True, | ||
"regime_entries": [], | ||
} | ||
) | ||
assessment_payload.append(data) | ||
|
||
response = api_client.put( | ||
url, | ||
assessment_payload, | ||
**gov_headers, | ||
) | ||
assert response.status_code == 200, response.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from pytest_bdd import scenarios | ||
|
||
|
||
scenarios("./scenarios/goods_ratings.feature") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters