From 94ba9e96266ac99731b16d0047ac1458d73f8145 Mon Sep 17 00:00:00 2001 From: Sampo Tawast <5328394+sirtawast@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:10:48 +0300 Subject: [PATCH] fix: remove employee consent attachment limit to 1 (#3221) --- .../applications/api/v1/serializers/application.py | 6 ------ .../applications/tests/test_applications_api.py | 14 +++++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/backend/benefit/applications/api/v1/serializers/application.py b/backend/benefit/applications/api/v1/serializers/application.py index 2ae6890306..4243848a53 100755 --- a/backend/benefit/applications/api/v1/serializers/application.py +++ b/backend/benefit/applications/api/v1/serializers/application.py @@ -1211,12 +1211,6 @@ def _validate_employee_consent(self, instance): raise serializers.ValidationError( _("Application does not have the employee consent attachment") ) - if consent_count > 1: - raise serializers.ValidationError( - _( - "Application cannot have more than one employee consent attachment" - ) - ) def _update_applicant_terms_approval(self, instance, approve_terms): if ApplicantTermsApproval.terms_approval_needed(instance): diff --git a/backend/benefit/applications/tests/test_applications_api.py b/backend/benefit/applications/tests/test_applications_api.py index da525b8ea0..06f1021629 100755 --- a/backend/benefit/applications/tests/test_applications_api.py +++ b/backend/benefit/applications/tests/test_applications_api.py @@ -2072,6 +2072,7 @@ def test_employee_consent_upload(request, api_client, application, settings): application.pay_subsidy_percent = 50 application.apprenticeship_program = False application.save() + # add the required attachments except consent response = _upload_pdf( request, @@ -2096,7 +2097,7 @@ def test_employee_consent_upload(request, api_client, application, settings): == "Application does not have the employee consent attachment" ) - # upload the consent + # upload the consent two times _upload_pdf( request, api_client, @@ -2115,24 +2116,19 @@ def test_employee_consent_upload(request, api_client, application, settings): ).count() == 2 ) - # Cannot upload multiple employee consent response = _submit_application(api_client, application) - assert response.status_code == 400 - assert ( - str(response.data[0]) - == "Application cannot have more than one employee consent attachment" - ) + assert response.status_code == 200 + application.attachments.filter(attachment_type=AttachmentType.EMPLOYEE_CONSENT)[ 0 ].delete() + assert ( application.attachments.filter( attachment_type=AttachmentType.EMPLOYEE_CONSENT ).count() == 1 ) - response = _submit_application(api_client, application) - assert response.status_code == 200 application.refresh_from_db() assert application.status == ApplicationStatus.RECEIVED