diff --git a/api/data_workspace/v2/tests/bdd/conftest.py b/api/data_workspace/v2/tests/bdd/conftest.py index ffc4710d7..fc4f49568 100644 --- a/api/data_workspace/v2/tests/bdd/conftest.py +++ b/api/data_workspace/v2/tests/bdd/conftest.py @@ -393,6 +393,9 @@ def _issue_licence(application): good_on_app.save() data[f"quantity-{good_on_app.id}"] = str(good_on_app.quantity) data[f"value-{good_on_app.id}"] = str(good_on_app.value) + # create final advice for controlled goods; skip NLR goods + if good_on_app.is_good_controlled == False: + continue FinalAdviceFactory(user=lu_case_officer, case=application, good=good_on_app.good) issue_date = datetime.datetime.now() diff --git a/api/data_workspace/v2/tests/bdd/scenarios/goods_on_licences.feature b/api/data_workspace/v2/tests/bdd/scenarios/goods_on_licences.feature index 1e78d22ed..ce3c4a9e4 100644 --- a/api/data_workspace/v2/tests/bdd/scenarios/goods_on_licences.feature +++ b/api/data_workspace/v2/tests/bdd/scenarios/goods_on_licences.feature @@ -12,3 +12,20 @@ Scenario: Issue a licence Then the `goods_on_licences` table has the following rows: | good_id | licence_id | | 61d193bd-a4d8-4f7d-8c07-1ac5e03ea2c7 | 962b4948-b87a-42fe-9c2b-61bdefd9cd21 | + +Scenario: NLR goods not on licence + Given a standard application with the following goods: + | id | name | + | aa9736f9-48f5-4d44-ace9-e4b8738591a5 | Another controlled good | + | 56f562f6-b554-4bb3-923b-8695ab15afca | An NLR good | + And the goods are assessed by TAU as: + | id | Control list entry | Report summary prefix | Report summary subject | + | aa9736f9-48f5-4d44-ace9-e4b8738591a5 | ML5b | accessories for | network analysers | + | 56f562f6-b554-4bb3-923b-8695ab15afca | NLR | | | + And a draft licence with attributes: + | name | value | + | id | 847a9a03-c35f-4036-ab8c-8b58d13482ab | + When the licence is issued + Then the `goods_on_licences` table has the following rows: + | good_id | licence_id | + | aa9736f9-48f5-4d44-ace9-e4b8738591a5 | 847a9a03-c35f-4036-ab8c-8b58d13482ab | diff --git a/api/data_workspace/v2/tests/bdd/test_goods_on_licences.py b/api/data_workspace/v2/tests/bdd/test_goods_on_licences.py index b63dc856b..f545efbfd 100644 --- a/api/data_workspace/v2/tests/bdd/test_goods_on_licences.py +++ b/api/data_workspace/v2/tests/bdd/test_goods_on_licences.py @@ -1,8 +1,13 @@ +from django.urls import reverse from pytest_bdd import given, parsers, scenarios, when from api.applications.tests.factories import GoodOnApplicationFactory from api.licences.tests.factories import StandardLicenceFactory from api.licences.enums import LicenceStatus +from api.staticdata.report_summaries.models import ( + ReportSummaryPrefix, + ReportSummarySubject, +) scenarios("./scenarios/goods_on_licences.feature") @@ -31,5 +36,56 @@ def draft_licence_with_attributes(parse_attributes, attributes, standard_applica @when("the licence is issued") def licence_is_issued(standard_application, issue_licence): issue_licence(standard_application) - issued_application = standard_application.refresh_from_db() - return issued_application + standard_application.refresh_from_db() + return standard_application + + +@given(parsers.parse("the goods are assessed by TAU as:{assessments}")) +def the_goods_are_assessed_by_tau_as( + parse_table, + standard_application, + assessments, + api_client, + lu_case_officer, + gov_headers, +): + assessments = parse_table(assessments)[1:] + url = reverse("assessments:make_assessments", kwargs={"case_pk": 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