From 9bcb39599785d7dc5cf6e49ecb12231d51afe1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bovard?= Date: Wed, 12 Jun 2024 12:23:16 +0200 Subject: [PATCH] Add UI test when validation by validators is disabled --- .../functional/test_submission_validation.py | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/geocity/tests/submissions/functional/test_submission_validation.py b/geocity/tests/submissions/functional/test_submission_validation.py index 760815da8..e5afac2a3 100644 --- a/geocity/tests/submissions/functional/test_submission_validation.py +++ b/geocity/tests/submissions/functional/test_submission_validation.py @@ -67,6 +67,76 @@ def test_secretariat_cannot_request_validation_for_already_validated_submission( self.assertEqual(response.status_code, 400) + def test_secretariat_see_validation_tab_for_submitted_submission( + self, + ): + validator_group = factories.ValidatorGroupFactory( + department__administrative_entity=self.administrative_entity + ) + submission = factories.SubmissionFactory( + author=self.user, + administrative_entity=self.administrative_entity, + ) + form = factories.FormWithoutGeometryFactory( + needs_date=False, + ) + submission.forms.set([form]) + self.client.post( + reverse( + "submissions:submission_submit", + kwargs={"submission_id": submission.pk}, + ), + data={ + "departments": [validator_group.permit_department.pk], + }, + ) + submission.refresh_from_db() + + response = self.client.get( + reverse( + "submissions:submission_detail", + kwargs={"submission_id": submission.pk}, + ) + ) + self.assertEqual(response.status_code, 200) + parser = get_parser(response.content) + self.assertEqual(len(parser.select("#request-validation")), 1) + + def test_secretariat_cannot_see_validation_tab_for_submitted_submission_when_validation_is_disabled( + self, + ): + validator_group = factories.ValidatorGroupFactory( + department__administrative_entity=self.administrative_entity + ) + submission = factories.SubmissionFactory( + author=self.user, + administrative_entity=self.administrative_entity, + ) + form = factories.FormWithoutGeometryFactory( + needs_date=False, disable_validation_by_validators=True + ) + submission.forms.set([form]) + self.client.post( + reverse( + "submissions:submission_submit", + kwargs={"submission_id": submission.pk}, + ), + data={ + "departments": [validator_group.permit_department.pk], + }, + ) + submission.refresh_from_db() + + response = self.client.get( + reverse( + "submissions:submission_detail", + kwargs={"submission_id": submission.pk}, + ) + ) + self.assertEqual(response.status_code, 200) + parser = get_parser(response.content) + self.assertEqual(len(parser.select("#request-validation")), 0) + def test_default_departments_are_checked(self): default_validator_groups = factories.ValidatorGroupFactory.create_batch( 2,