Skip to content

Commit

Permalink
update tests as per new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sekharpanja committed Feb 22, 2022
1 parent 72a893a commit b8d1a0b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion api/applications/serializers/temporary_export_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def validate(self, data):
data, "temp_export_details", strings.Generic.TemporaryExportDetails.Error.TEMPORARY_EXPORT_DETAILS
)
is_temp_direct_control_value = validate_field(
data, "is_temp_direct_control", strings.Generic.TemporaryExportDetails.Error.PRODUCTS_UNDER_DIRECT_CONTROL, required=True
data,
"is_temp_direct_control",
strings.Generic.TemporaryExportDetails.Error.PRODUCTS_UNDER_DIRECT_CONTROL,
)

# Only validate temp_direct_control_details if its parent is_temp_direct_control is False
Expand Down
4 changes: 2 additions & 2 deletions api/applications/tests/test_create_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def test_create_draft_standard_individual_export_application_empty_export_type_s

response = self.client.post(self.url, data, **self.exporter_headers)
response_data = response.json()
standard_application = StandardApplication.objects.get()

self.assertEqual(response.status_code, status.HTTP_201_CREATED)

standard_application = StandardApplication.objects.get()
self.assertEqual(response_data["id"], str(standard_application.id))
self.assertEqual(StandardApplication.objects.count(), 1)

Expand Down
2 changes: 1 addition & 1 deletion api/applications/tests/test_edit_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_edit_unsubmitted_application_name_success(self):
self.assertEqual(Audit.objects.count(), 0)

def test_edit_unsubmitted_application_export_type_success(self):
""" Test edit the application export_type of an unsubmitted application. An unsubmitted application
"""Test edit the application export_type of an unsubmitted application. An unsubmitted application
has the 'draft' status.
"""
application = self.create_draft_standard_application(self.organisation)
Expand Down
13 changes: 12 additions & 1 deletion api/applications/tests/test_standard_application_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_submit_standard_application_without_end_user_document_failure(self):

def test_submit_standard_application_without_consignee_failure(self):
self.draft.delete_party(self.draft.consignee)
self.draft.goods_recipients = StandardApplication.DIRECT_TO_END_USER
self.draft.goods_recipients = StandardApplication.VIA_CONSIGNEE
self.draft.save()

url = reverse("applications:application_submit", kwargs={"pk": self.draft.id})
Expand All @@ -135,6 +135,17 @@ def test_submit_standard_application_without_consignee_failure(self):
status_code=status.HTTP_400_BAD_REQUEST,
)

def test_submit_standard_application_direct_end_user_without_consignee_success(self):
self.draft.delete_party(self.draft.consignee)
self.draft.goods_recipients = StandardApplication.DIRECT_TO_END_USER
self.draft.save()

url = reverse("applications:application_submit", kwargs={"pk": self.draft.id})

response = self.client.put(url, **self.exporter_headers)

self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_submit_standard_application_without_consignee_document_success(self):
# Consignee document is optional
PartyDocument.objects.filter(party=self.draft.consignee.party).delete()
Expand Down

0 comments on commit b8d1a0b

Please sign in to comment.