From bd16d468e13a4e0952c116c38bbef2d68dd2bc18 Mon Sep 17 00:00:00 2001 From: Brendan Smith Date: Fri, 13 Dec 2024 16:10:54 +0000 Subject: [PATCH 01/10] Content tweaks to queue view exclude flags filter --- caseworker/queues/views/forms.py | 11 +++++++---- .../caseworker/cases/views/test_case_bookmarks.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/caseworker/queues/views/forms.py b/caseworker/queues/views/forms.py index c48380119d..ab82849574 100644 --- a/caseworker/queues/views/forms.py +++ b/caseworker/queues/views/forms.py @@ -172,18 +172,16 @@ def __init__(self, queue, filters_data, all_flags, all_cles, all_regimes, countr flag_url = reverse("flags:flags") self.fields["flags"] = forms.MultipleChoiceField( - label="Flags", + label="Show only cases with these flags", choices=flags_choices, required=False, - help_text=f'Flag information (open in a new window)', # setting id for javascript to use widget=forms.SelectMultiple(attrs={"id": "flags"}), ) self.fields["exclude_flags"] = forms.MultipleChoiceField( - label="Exclude flags", + label="Do not show cases with these flags", choices=flags_choices, required=False, - help_text=f'Flag information (open in a new window)', # setting id for javascript to use widget=forms.SelectMultiple(attrs={"id": "exclude_flags"}), ) @@ -229,6 +227,11 @@ def __init__(self, queue, filters_data, all_flags, all_cles, all_regimes, countr "submitted_to", Field("flags", css_class="multi-select-filter"), Field("exclude_flags", css_class="multi-select-filter"), + HTML( + '
' + f'Flag information (open in a new window)' + "
" + ), "finalised_from", "finalised_to", ] diff --git a/unit_tests/caseworker/cases/views/test_case_bookmarks.py b/unit_tests/caseworker/cases/views/test_case_bookmarks.py index eb977ad07f..e8a21beb76 100644 --- a/unit_tests/caseworker/cases/views/test_case_bookmarks.py +++ b/unit_tests/caseworker/cases/views/test_case_bookmarks.py @@ -72,6 +72,6 @@ def test_bookmarks_present( assert third["filter_json"] == { "flags": ["64cbcf98-9beb-41ad-8f5d-276dee768990", "8f02e308-9861-4284-a7f0-f05495efce31"] } - assert third["description"] == "Flags: AG Biological, AG Chemical" + assert third["description"] == "Show only cases with these flags: AG Biological, AG Chemical" assert "flags=64cbcf98-9beb-41ad-8f5d-276dee768990" in third["url"] assert "flags=8f02e308-9861-4284-a7f0-f05495efce31" in third["url"] From 24ec9f35c790a81e993d8a86bd5a7ba4326908b4 Mon Sep 17 00:00:00 2001 From: Brendan Smith Date: Mon, 16 Dec 2024 17:01:10 +0000 Subject: [PATCH 02/10] Add E2E tests for licence condtions pre-fill --- .../templates/advice/advice_details.html | 2 +- .../give_advice/lu_consolidate_advice.feature | 74 +++++++++++++++++++ ui_tests/caseworker/pages/advice.py | 4 +- .../step_defs/test_give_advice/conftest.py | 5 ++ 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/caseworker/advice/templates/advice/advice_details.html b/caseworker/advice/templates/advice/advice_details.html index 88da2ba709..fcf62e4a24 100644 --- a/caseworker/advice/templates/advice/advice_details.html +++ b/caseworker/advice/templates/advice/advice_details.html @@ -129,7 +129,7 @@

Reason for approving

{% if advice.0.proviso %}

Licence condition

-

{{ advice.0.proviso|linebreaks }}

+
{{ advice.0.proviso|linebreaks }}
{% endif %} {% if advice.0.note %} diff --git a/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature b/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature index 8a54e2a4da..0e901cbde2 100644 --- a/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature +++ b/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature @@ -52,3 +52,77 @@ Feature: I want to record my user advice and any comments and conditions relatin And I click on "Details" tab Then I see the case status is now "Finalised" And I see the case is not assigned to any queues + + @lu_consolidate_advice_ogd_licence_conditions + Scenario: LU consolidate advice with OGD licence conditions + Given I sign in as Test UAT user + And I create standard application or standard application has been previously created + # LR + When I switch to "Licensing Reception" with queue "Licensing Reception SIEL applications" and I submit the case + Then I see the case status is now "Initial checks" + And I see the case is assigned to queues "Enforcement Unit Cases to Review, Technical Assessment Unit SIELs to Review" + # EU + When I switch to "Enforcement Unit" with queue "Enforcement Unit Cases to Review" and I submit the case + Then I see the case status is now "Initial checks" + And I see the case is assigned to queues "Technical Assessment Unit SIELs to Review" + And I see the case is not assigned to queues "Enforcement Unit Cases to Review" + # TAU + When I go to my profile page + And I change my team to "Technical Assessment Unit" and default queue to "Technical Assessment Unit SIELs to Review" + And I go to my case list + Then I see previously created application + When I click on the application previously created + And I assign myself to the case + Then I click on Product assessment + And I select good + And I select the CLE "ML1a" + And I select "components for" / "microwave components" as report summary prefix / subject and regime to none and submit + When I click move case forward + Then I don't see previously created application + # LU + When I switch to "Licensing Unit" with queue "Licensing Unit Pre-circulation Cases to Review" and I submit the case + Then I see the case status is now "OGD Advice" + And I see the case is assigned to queues "MOD-DI Indirect cases to review, MOD-CapProt cases to review, FCDO Cases to Review" + # MOD-DI + When I switch to "MOD-DI" with queue "MOD-DI Indirect cases to review" and I submit the case + Then I see the case status is now "OGD Advice" + And I see the case is assigned to queues "MOD-CapProt cases to review, FCDO Cases to Review" + + ##### Sub-advisor to give advice ##### + When I go to my profile page + And I change my team to "MOD-CapProt" and default queue to "MOD-CapProt cases to review" + And I go to my case list + Then I should see my case in the cases list + When I click the application previously created + And I assign myself to the case + And I click the recommendations and decision tab + And I click make recommendation + And I click approve all + And I click continue + And I enter "reason for approving" as the reasons for approving + And I click the text "Add a licence condition, instruction to exporter or footnote" + And I enter "MOD licence condition" as the licence condition + And I enter "instruction for exporter" as the instructions for the exporter + And I enter "reporting footnote" as the reporting footnote + And I click submit recommendation + Then I see "reason for approving" as the reasons for approving + And I see "MOD licence condition" as the licence condition + And I see "instruction for exporter" as the instructions for the exporter + And I see "reporting footnote" as the reporting footnote + When I logout + Given I sign in as Licensing Unit Officer + And I prepare the application for final review + When I go to my case list + And I go to my case list + And I click the application previously created + And I assign myself as case officer to the case + And I go to my case list + And I click the application previously created + And I click the recommendations and decision tab + And I click "Review and combine" + And I enter "reason for approving" as the reasons for approving + And I click "Add licence condition" + And I click submit recommendation + Then I see "reason for approving" as the reasons for approving + And I see "MOD licence condition" in the licence condition + And I see "serial numbers" in the licence condition diff --git a/ui_tests/caseworker/pages/advice.py b/ui_tests/caseworker/pages/advice.py index 7cf2de31fa..47d685c6d6 100644 --- a/ui_tests/caseworker/pages/advice.py +++ b/ui_tests/caseworker/pages/advice.py @@ -165,8 +165,8 @@ def get_refusal_note(self): def get_licence_condition(self): return self.driver.find_element( - by=By.XPATH, - value="//p[preceding-sibling::*[self::h2 or self::h3][contains(text(), 'Licence condition')]][2]", + by=By.CLASS_NAME, + value="licence-condition", ).text def get_instructions_for_exporter(self): diff --git a/ui_tests/caseworker/step_defs/test_give_advice/conftest.py b/ui_tests/caseworker/step_defs/test_give_advice/conftest.py index ab9dc74ee8..d22b7034ea 100644 --- a/ui_tests/caseworker/step_defs/test_give_advice/conftest.py +++ b/ui_tests/caseworker/step_defs/test_give_advice/conftest.py @@ -133,6 +133,11 @@ def should_see_licence_condition(driver, licence_condition, context): # noqa assert RecommendationsAndDecisionPage(driver).get_licence_condition() == licence_condition +@then(parsers.parse('I see "{licence_condition}" in the licence condition')) +def should_see_licence_condition(driver, licence_condition, context): # noqa + assert licence_condition in RecommendationsAndDecisionPage(driver).get_licence_condition() + + @then(parsers.parse('I see "{instructions}" as the instructions for the exporter')) def should_see_instructions_for_exporter(driver, instructions, context): # noqa assert RecommendationsAndDecisionPage(driver).get_instructions_for_exporter() == instructions From a5f3df9e499cae36e7c24805e8bb3748ca80c17f Mon Sep 17 00:00:00 2001 From: Brendan Smith Date: Tue, 17 Dec 2024 14:37:24 +0000 Subject: [PATCH 03/10] Make licence condition selectable by UI tests in grouped advice --- caseworker/advice/templates/advice/group-advice.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caseworker/advice/templates/advice/group-advice.html b/caseworker/advice/templates/advice/group-advice.html index 0c92fbbea2..55b4fdee73 100644 --- a/caseworker/advice/templates/advice/group-advice.html +++ b/caseworker/advice/templates/advice/group-advice.html @@ -105,7 +105,7 @@

Reasons for refusing

Licence condition

-

{{ advice.proviso|linebreaks }}

+
{{ advice.proviso|linebreaks }}
From dd3840f825abee105c0b2c0fe8870f01be3cdfa8 Mon Sep 17 00:00:00 2001 From: Brendan Smith Date: Fri, 20 Dec 2024 16:12:22 +0000 Subject: [PATCH 04/10] Extend E2E test to demonstrate combining multiple licence conditions --- .../give_advice/lu_consolidate_advice.feature | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature b/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature index 0e901cbde2..25b69321fc 100644 --- a/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature +++ b/ui_tests/caseworker/features/give_advice/lu_consolidate_advice.feature @@ -88,7 +88,7 @@ Feature: I want to record my user advice and any comments and conditions relatin Then I see the case status is now "OGD Advice" And I see the case is assigned to queues "MOD-CapProt cases to review, FCDO Cases to Review" - ##### Sub-advisor to give advice ##### + ##### MOD Sub-advisor to give advice ##### When I go to my profile page And I change my team to "MOD-CapProt" and default queue to "MOD-CapProt cases to review" And I go to my case list @@ -109,6 +109,30 @@ Feature: I want to record my user advice and any comments and conditions relatin And I see "MOD licence condition" as the licence condition And I see "instruction for exporter" as the instructions for the exporter And I see "reporting footnote" as the reporting footnote + + ##### FCDO Sub-advisor to give advice ##### + When I go to my profile page + And I change my team to "FCDO" and default queue to "FCDO Cases to Review" + And I go to my case list + Then I should see my case in the cases list + When I click the application previously created + And I assign myself to the case + And I click the recommendations and decision tab + And I click make recommendation + And I click approve all + And I click continue + And I select countries "GB, UA" + And I enter "reason for approving" as the reasons for approving + And I click the text "Add a licence condition, instruction to exporter or footnote" + And I enter "FCDO licence condition" as the licence condition + And I enter "instruction for exporter" as the instructions for the exporter + And I enter "reporting footnote" as the reporting footnote + And I click submit recommendation + Then I see "reason for approving" as the reasons for approving + And I see "FCDO licence condition" as the licence condition + And I see "instruction for exporter" as the instructions for the exporter + And I see "reporting footnote" as the reporting footnote + When I logout Given I sign in as Licensing Unit Officer And I prepare the application for final review @@ -125,4 +149,5 @@ Feature: I want to record my user advice and any comments and conditions relatin And I click submit recommendation Then I see "reason for approving" as the reasons for approving And I see "MOD licence condition" in the licence condition + And I see "FCDO licence condition" in the licence condition And I see "serial numbers" in the licence condition From 28d0124446bb35acd29ade7ea7252595f2006533 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Wed, 18 Dec 2024 15:11:06 +0000 Subject: [PATCH 05/10] Add tests for variable highlight --- unit_tests/caseworker/test_template_tags.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/unit_tests/caseworker/test_template_tags.py b/unit_tests/caseworker/test_template_tags.py index c3d227f2a9..f008957fd0 100644 --- a/unit_tests/caseworker/test_template_tags.py +++ b/unit_tests/caseworker/test_template_tags.py @@ -1,6 +1,7 @@ from core.builtins import custom_tags from caseworker.core.constants import SLA_CIRCUMFERENCE +from caseworker.letter_templates.templatetags.variable_highlight import variable_highlight import pytest @@ -60,3 +61,20 @@ def test_sla_colour(remaining, unit, colour): def test_sla_colour_missing_unit(): with pytest.raises(ValueError): custom_tags.sla_colour(10, "") + + +@pytest.mark.parametrize( + "input, expected", + ( + ("just text", "just text"), + ("with {{ variable }}", 'with {{ variable }}'), + ( + "with {% another_variable %}", + 'with {% another_variable %}', + ), + ("Link", "Link"), + ("", "<script>alert()</script>"), + ), +) +def test_variable_highlight(input, expected): + assert variable_highlight(input) == expected From e59490f4759f6b8923e8f72404d61a2c44412b77 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Thu, 19 Dec 2024 09:59:49 +0000 Subject: [PATCH 06/10] Add tests for govuk link button template tag --- .../lite_internal_frontend/strings.py | 1 + lite_content/lite_internal_frontend/tests.py | 2 + unit_tests/conftest.py | 21 +++++++++- .../templatetags/test_custom_tags.py | 41 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 lite_content/lite_internal_frontend/tests.py diff --git a/lite_content/lite_internal_frontend/strings.py b/lite_content/lite_internal_frontend/strings.py index 7f77a92975..76631d6e34 100644 --- a/lite_content/lite_internal_frontend/strings.py +++ b/lite_content/lite_internal_frontend/strings.py @@ -13,6 +13,7 @@ queues, # noqa picklists, # noqa routing_rules, # noqa + tests, # noqa ) # noqa # Buttons diff --git a/lite_content/lite_internal_frontend/tests.py b/lite_content/lite_internal_frontend/tests.py new file mode 100644 index 0000000000..8bb74bbb60 --- /dev/null +++ b/lite_content/lite_internal_frontend/tests.py @@ -0,0 +1,2 @@ +class TestPage: + BUTTON = "Test Button" diff --git a/unit_tests/conftest.py b/unit_tests/conftest.py index a7dcddb6ab..0f8dca8f0a 100644 --- a/unit_tests/conftest.py +++ b/unit_tests/conftest.py @@ -2602,12 +2602,29 @@ def _create_files(*files): return _create_files -@pytest.fixture +@pytest.fixture() +def authorized_client(client): + return client + + +@pytest.fixture() def mock_request(rf, authorized_client): request = rf.get("/") request.session = authorized_client.session request.requests_session = requests.Session() - yield request + return request + + +@pytest.fixture() +def render_template_string(mock_request): + def _render_template_string(template_string, context=None): + if not context: + context = {} + template = Template(template_string) + context = RequestContext(mock_request, context) + return template.render(context) + + return _render_template_string @pytest.fixture() diff --git a/unit_tests/lite_forms/templatetags/test_custom_tags.py b/unit_tests/lite_forms/templatetags/test_custom_tags.py index 3932438a69..45ddf72036 100644 --- a/unit_tests/lite_forms/templatetags/test_custom_tags.py +++ b/unit_tests/lite_forms/templatetags/test_custom_tags.py @@ -1,5 +1,7 @@ import pytest +from pytest_django.asserts import assertHTMLEqual + from lite_forms.templatetags import custom_tags @@ -12,3 +14,42 @@ ) def test_file_type(filename, expected): assert expected == custom_tags.file_type(filename) + + +@pytest.mark.parametrize( + "input, context, expected", + [ + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' %}", + {}, + 'Test Button', + ), + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' id='test-id' classes='govuk-button--secondary' %}", + {}, + 'Test Button', + ), + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' show_chevron=True %}", + {}, + 'Test Button', + ), + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' query_params='?foo=bar' %}", + {}, + 'Test Button', + ), + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' hidden=True %}", + {}, + '', + ), + ( + "{% govuk_link_button text='tests.TestPage.BUTTON' url='core:index' query_params=html_content %}", + {"html_content": '">fooTest Button', + ), + ], +) +def test_govuk_link_button(render_template_string, input, context, expected): + assertHTMLEqual(render_template_string(input, context), expected) From d16936d65b2ca1a127c2288b787e68d012bf1ab6 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Thu, 19 Dec 2024 11:53:10 +0000 Subject: [PATCH 07/10] Switch govuk link button to an inclusion tag This is to ensure that any potential HTML tags are sanitised correctly through using Django's template engine --- lite_forms/templates/govuk-link-button.html | 8 +++++ lite_forms/templatetags/custom_tags.py | 35 ++++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 lite_forms/templates/govuk-link-button.html diff --git a/lite_forms/templates/govuk-link-button.html b/lite_forms/templates/govuk-link-button.html new file mode 100644 index 0000000000..400a4c017a --- /dev/null +++ b/lite_forms/templates/govuk-link-button.html @@ -0,0 +1,8 @@ + diff --git a/lite_forms/templatetags/custom_tags.py b/lite_forms/templatetags/custom_tags.py index 97857f37d8..0276747954 100644 --- a/lite_forms/templatetags/custom_tags.py +++ b/lite_forms/templatetags/custom_tags.py @@ -6,7 +6,6 @@ from django.urls import reverse from django.utils.safestring import mark_safe -from core.builtins.custom_tags import get_const_string from lite_forms.helpers import flatten_data @@ -199,27 +198,25 @@ def item_with_rating_exists(items, rating): return True -@register.simple_tag -@mark_safe # noqa: S308 +@register.inclusion_tag("govuk-link-button.html") def govuk_link_button(text, url, url_param=None, id="", classes="", query_params="", show_chevron=False, hidden=False): - text = get_const_string(text) + if not url_param: + url_param = [] + if isinstance(url_param, str): url_param = [url_param] - url = reverse(url, args=url_param if url_param else []) - id = f'id="button-{id}"' if id else "" - chevron = "" - if show_chevron: - chevron = ( - '' - ) - hidden = 'style="display: none;"' if hidden else "" - - return ( - f'{text}{chevron}' - ) + + url = reverse(url, args=url_param) + + return { + "text": text, + "url": url, + "id": id, + "classes": classes, + "show_chevron": show_chevron, + "hidden": hidden, + "query_params": query_params, + } @register.filter() From 3416e1e6561f7f57f659b41b6738556e6043d194 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Thu, 19 Dec 2024 09:59:49 +0000 Subject: [PATCH 08/10] Ensure the hidden_field template tag doesn't need to use mark_safe --- core/builtins/custom_tags.py | 5 ++- .../inclusion_tags/hidden-field.html | 1 + unit_tests/core/builtins/test_custom_tags.py | 32 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 core/templates/inclusion_tags/hidden-field.html diff --git a/core/builtins/custom_tags.py b/core/builtins/custom_tags.py index 4cac4e3adf..8ca4783fe7 100644 --- a/core/builtins/custom_tags.py +++ b/core/builtins/custom_tags.py @@ -178,13 +178,12 @@ def str_date_only(value): return localtime(parse(value)).strftime("%-d %B %Y") -@register.simple_tag -@mark_safe # noqa: S308 +@register.inclusion_tag("inclusion_tags/hidden-field.html") def hidden_field(key, value): """ Generates a hidden field from the given key and value """ - return f'' + return {"key": key, "value": value} @register.filter() diff --git a/core/templates/inclusion_tags/hidden-field.html b/core/templates/inclusion_tags/hidden-field.html new file mode 100644 index 0000000000..44db06f0ff --- /dev/null +++ b/core/templates/inclusion_tags/hidden-field.html @@ -0,0 +1 @@ + diff --git a/unit_tests/core/builtins/test_custom_tags.py b/unit_tests/core/builtins/test_custom_tags.py index 388b8c7c6b..22542a42fc 100644 --- a/unit_tests/core/builtins/test_custom_tags.py +++ b/unit_tests/core/builtins/test_custom_tags.py @@ -1,6 +1,8 @@ import datetime import pytest +from pytest_django.asserts import assertHTMLEqual + from decimal import Decimal from core.builtins import custom_tags @@ -426,3 +428,33 @@ def test_pagination_params(url, page, expected): def test_pagination(): with pytest.raises(ValueError): custom_tags.pagination({}, link_type="madeup") + + +@pytest.mark.parametrize( + "input, context, expected", + [ + ( + "{% hidden_field 'test-key' 'test-value' %}", + {}, + '', + ), + ( + "{% hidden_field key value %}", + { + "key": "test-key", + "value": "test-value", + }, + '', + ), + ( + "{% hidden_field key value %}", + { + "key": '">', + ), + ], +) +def test_hidden_field(render_template_string, input, context, expected): + assertHTMLEqual(render_template_string(input, context), expected) From 5dbf32309cf9226137f3de47720c0aa9e3de1e6e Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Fri, 3 Jan 2025 13:19:02 +0000 Subject: [PATCH 09/10] Use dynamic future year to stop tests failing --- unit_tests/exporter/goods/forms/test_forms.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/unit_tests/exporter/goods/forms/test_forms.py b/unit_tests/exporter/goods/forms/test_forms.py index 1cd864af95..263b6b1472 100644 --- a/unit_tests/exporter/goods/forms/test_forms.py +++ b/unit_tests/exporter/goods/forms/test_forms.py @@ -1,3 +1,5 @@ +import datetime + from unittest.mock import patch import pytest @@ -590,25 +592,28 @@ def test_registered_firearms_dealer_form(data, valid, error_field, error_message assert form.errors[error_field][0] == error_message +FUTURE_YEAR = str(datetime.date.today().year + 1) + + @pytest.mark.parametrize( "data, files, valid, error_field, error_message", ( ( - {"reference_code": "ref_code", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": 2025}, + {"reference_code": "ref_code", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": FUTURE_YEAR}, {"file": SimpleUploadedFile("test", b"test_content")}, True, None, None, ), ( - {"reference_code": "ref_code", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": 2025}, + {"reference_code": "ref_code", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": FUTURE_YEAR}, {"file": ""}, False, "file", "Select certificate file to upload", ), ( - {"reference_code": "", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": 2025}, + {"reference_code": "", "expiry_date_0": 1, "expiry_date_1": 1, "expiry_date_2": FUTURE_YEAR}, {"file": SimpleUploadedFile("test", b"test_content")}, False, "reference_code", @@ -638,7 +643,7 @@ def test_attach_fiream_dealer_certificate_form(data, files, valid, error_field, if valid: assert form.cleaned_data["expiry_date_day"] == "1" assert form.cleaned_data["expiry_date_month"] == "1" - assert form.cleaned_data["expiry_date_year"] == "2025" + assert form.cleaned_data["expiry_date_year"] == str(FUTURE_YEAR) else: assert form.errors[error_field][0] == error_message From 6558230204c0b10f22890046795f1e42c300a1c6 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Fri, 3 Jan 2025 13:23:27 +0000 Subject: [PATCH 10/10] Remove superfluous str call --- unit_tests/exporter/goods/forms/test_forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_tests/exporter/goods/forms/test_forms.py b/unit_tests/exporter/goods/forms/test_forms.py index 263b6b1472..e1e7e30dcf 100644 --- a/unit_tests/exporter/goods/forms/test_forms.py +++ b/unit_tests/exporter/goods/forms/test_forms.py @@ -592,7 +592,7 @@ def test_registered_firearms_dealer_form(data, valid, error_field, error_message assert form.errors[error_field][0] == error_message -FUTURE_YEAR = str(datetime.date.today().year + 1) +FUTURE_YEAR = datetime.date.today().year + 1 @pytest.mark.parametrize(