From e16a8adc78837e708520768b1428534f8e532f8e Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Tue, 3 Dec 2024 11:16:30 -0700 Subject: [PATCH 01/11] updated test_views.py to cover several tests --- backend/audit/test_views.py | 522 ++++++++++++++++++++++++++++++++++-- 1 file changed, 495 insertions(+), 27 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 1c5b0dfcf..1adab04f2 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -1,43 +1,36 @@ -from datetime import datetime, timezone import json +from datetime import datetime, timezone from pathlib import Path from tempfile import NamedTemporaryFile from unittest.mock import patch -from django.test import Client, TestCase, TransactionTestCase -from django.contrib.auth import get_user_model -from django.core.files.uploadedfile import SimpleUploadedFile -from django.urls import reverse - -from faker import Faker - -from model_bakery import baker - -from openpyxl import load_workbook -from openpyxl.cell import Cell - +from audit.cross_validation.naming import SECTION_NAMES as SN from audit.fixtures.excel import ( - ADDITIONAL_UEIS_TEMPLATE, + ADDITIONAL_EINS_ENTRY_FIXTURES, ADDITIONAL_EINS_TEMPLATE, - FEDERAL_AWARDS_TEMPLATE, + ADDITIONAL_UEIS_ENTRY_FIXTURES, + ADDITIONAL_UEIS_TEMPLATE, + CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, CORRECTIVE_ACTION_PLAN_TEMPLATE, + FEDERAL_AWARDS_ENTRY_FIXTURES, + FEDERAL_AWARDS_TEMPLATE, + FINDINGS_TEXT_ENTRY_FIXTURES, FINDINGS_TEXT_TEMPLATE, + FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, FINDINGS_UNIFORM_GUIDANCE_TEMPLATE, - SECONDARY_AUDITORS_TEMPLATE, + FORM_SECTIONS, + NOTES_TO_SEFA_ENTRY_FIXTURES, NOTES_TO_SEFA_TEMPLATE, - CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, - FINDINGS_TEXT_ENTRY_FIXTURES, - FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, - FEDERAL_AWARDS_ENTRY_FIXTURES, - ADDITIONAL_UEIS_ENTRY_FIXTURES, - ADDITIONAL_EINS_ENTRY_FIXTURES, SECONDARY_AUDITORS_ENTRY_FIXTURES, - NOTES_TO_SEFA_ENTRY_FIXTURES, - FORM_SECTIONS, + SECONDARY_AUDITORS_TEMPLATE, ) from audit.fixtures.single_audit_checklist import ( - fake_auditor_certification, fake_auditee_certification, + fake_auditor_certification, +) +from audit.forms import ( + AuditeeCertificationStep2Form, + AuditorCertificationStep1Form, ) from audit.models import ( Access, @@ -47,9 +40,17 @@ generate_sac_report_id, ) from audit.models.models import STATUS -from audit.cross_validation.naming import SECTION_NAMES as SN -from audit.views import MySubmissions +from audit.views import AuditeeCertificationStep2View, MySubmissions from dissemination.models import FederalAward, General +from django.contrib.auth import get_user_model +from django.core.exceptions import PermissionDenied +from django.core.files.uploadedfile import SimpleUploadedFile +from django.test import Client, RequestFactory, TestCase, TransactionTestCase +from django.urls import reverse +from faker import Faker +from model_bakery import baker +from openpyxl import load_workbook +from openpyxl.cell import Cell User = get_user_model() @@ -264,16 +265,128 @@ def test_user_with_no_submissions_should_return_no_data(self): class EditSubmissionViewTests(TestCase): + def setUp(self): + self.client = Client() + self.user = baker.make(User) + self.url_name = "audit:EditSubmission" + self.report_id = "TEST_REPORT_ID" + def test_redirect_if_not_logged_in(self): result = self.client.get(reverse(EDIT_PATH, args=["SOME_REPORT_ID"])) self.assertAlmostEqual(result.status_code, 302) + def test_redirect_not_logged_in(self): + url = reverse(self.url_name, args=[self.report_id]) + response = self.client.get(url) + self.assertEqual(response.status_code, 302) + class SubmissionViewTests(TestCase): """ Testing for the final step: submitting. """ + def setUp(self): + self.client = Client() + self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, submission_status=STATUS.READY_FOR_CERTIFICATION + ) + self.url = reverse("audit:Submission", kwargs={"report_id": self.sac.report_id}) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditee_contact", + ) + + def test_get_renders_template(self): + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/submission.html") + self.assertIn("report_id", response.context) + self.assertIn("submission_status", response.context) + self.assertEqual(response.context["report_id"], self.sac.report_id) + self.assertEqual( + response.context["submission_status"], self.sac.submission_status + ) + + def test_get_permission_denied_if_no_sac(self): + invalid_url = reverse("audit:Submission", kwargs={"report_id": "INVALID"}) + response = self.client.get(invalid_url) + self.assertEqual(response.status_code, 403) + + def test_get_access_denied_for_unauthorized_user(self): + self.client.logout() + response = self.client.get(self.url) + self.assertEqual(response.status_code, 403) + + @patch("audit.views.views.SingleAuditChecklist.validate_full") + @patch("audit.views.views.sac_transition") + @patch("audit.views.views.remove_workbook_artifacts") + @patch("audit.views.views.SingleAuditChecklist.disseminate") + def test_post_valid_submission( + self, mock_disseminate, mock_remove, mock_transition, mock_validate + ): + mock_validate.return_value = [] + mock_disseminate.return_value = None + + response = self.client.post(self.url) + self.assertEqual(response.status_code, 302) + self.assertRedirects(response, reverse("audit:MySubmissions")) + + mock_transition.assert_any_call( + response.wsgi_request, self.sac, transition_to=STATUS.SUBMITTED + ) + mock_transition.assert_any_call( + response.wsgi_request, self.sac, transition_to=STATUS.DISSEMINATED + ) + mock_disseminate.assert_called_once() + mock_remove.assert_called_once_with(self.sac) + + @patch("audit.views.views.SingleAuditChecklist.validate_full") + @patch("audit.views.views.sac_transition") + @patch("audit.views.views.SingleAuditChecklist.disseminate") + def test_post_validation_errors( + self, mock_disseminate, mock_transition, mock_validate + ): + mock_validate.return_value = ["Error 1", "Error 2"] + + response = self.client.post(self.url) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed( + response, "audit/cross-validation/cross-validation-results.html" + ) + self.assertIn("errors", response.context) + self.assertListEqual(response.context["errors"], ["Error 1", "Error 2"]) + + mock_disseminate.assert_not_called() + mock_transition.assert_not_called() + + @patch("audit.views.views.General.objects.get") + @patch("audit.views.views.SingleAuditChecklist.validate_full") + def test_post_transaction_error(self, mock_validate, mock_general_get): + self.sac.submission_status = STATUS.AUDITEE_CERTIFIED + self.sac.save() + + mock_validate.return_value = [] + mock_general_get.return_value = True + + response = self.client.post(self.url) + + self.assertEqual(response.status_code, 302) + self.assertRedirects(response, reverse("audit:MySubmissions")) + + print("this response", response) + self.assertEqual(response.status_code, 302) + self.assertRedirects(response, reverse("audit:MySubmissions")) + + def test_post_permission_denied_if_no_sac(self): + invalid_url = reverse("audit:Submission", kwargs={"report_id": "INVALID"}) + response = self.client.post(invalid_url) + self.assertEqual(response.status_code, 403) + def test_post_redirect(self): """ The status should be "disseminated" after the post. @@ -330,6 +443,24 @@ def test_post_redirect(self): self.assertEqual(sac_after.submission_status, STATUSES.DISSEMINATED) +class SubmissionGetTest(TestCase): + def setUp(self): + self.user = baker.make(User) + self.client = Client() + self.url = reverse("audit:MySubmissions") + + def testValidSubmission(self): + self.client.force_login(self.user) + sac1 = baker.make(SingleAuditChecklist, submission_status=STATUS.IN_PROGRESS) + sac2 = baker.make(SingleAuditChecklist, submission_status=STATUS.DISSEMINATED) + baker.make(Access, user=self.user, sac=sac1) + baker.make(Access, user=self.user, sac=sac2) + + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/my_submissions.html") + + class SubmissionStatusTests(TransactionTestCase): """ Tests the expected order of progression for submission_status. @@ -1348,6 +1479,32 @@ def test_late_file_upload(self, mock_scan_file): "no_late_changes", response.content.decode("utf-8") ) + def test_get_login_required(self): + for form_section in FORM_SECTIONS: + response = self.client.get( + reverse( + f"audit:{form_section}", + kwargs={"report_id": "12345", "form_section": form_section}, + ) + ) + self.assertEqual(response.status_code, 403) + + def test_get_bad_report_id_returns_403(self): + user = baker.make(User) + self.client.force_login(user) + + for form_section in FORM_SECTIONS: + response = self.client.get( + reverse( + f"audit:{form_section}", + kwargs={ + "report_id": "this is not a report id", + "form_section": form_section, + }, + ) + ) + self.assertEqual(response.status_code, 403) + class SingleAuditReportFileHandlerViewTests(TestCase): def test_login_required(self): @@ -1656,3 +1813,314 @@ def test_valid_file_upload_for_notes_to_sefa(self, mock_scan_file): submission_events[event_count - 1].event, SubmissionEvent.EventType.NOTES_TO_SEFA_UPDATED, ) + + +class EditSubmissionTest(TestCase): + def setUp(self): + self.factory = RequestFactory() + self.client = Client() + self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, submission_status=STATUS.READY_FOR_CERTIFICATION + ) + self.url = reverse( + "audit:EditSubmission", kwargs={"report_id": self.sac.report_id} + ) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditee_contact", + ) + self.session = self.client.session + + def test_redirects_to_singleauditchecklist(self): + response = self.client.get(self.url) + self.assertRedirects( + response, reverse("singleauditchecklist", args=[self.sac.report_id]) + ) + + +class AuditorCertificationStep1ViewTests(TestCase): + def setUp(self): + self.client = Client() + self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, submission_status=STATUS.READY_FOR_CERTIFICATION + ) + self.url = reverse( + "audit:AuditorCertification", kwargs={"report_id": self.sac.report_id} + ) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditor_contact", + ) + self.session = self.client.session + + def test_get_redirects_if_status_not_ready_for_certification(self): + self.sac.submission_status = STATUS.IN_PROGRESS + self.sac.save() + response = self.client.get(self.url) + self.assertRedirects( + response, f"/audit/submission-progress/{self.sac.report_id}" + ) + + def test_get_renders_template_if_valid_state(self): + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/auditor-certification-step-1.html") + self.assertIn("form", response.context) + self.assertIsInstance(response.context["form"], AuditorCertificationStep1Form) + + def test_get_permission_denied_if_sac_not_found(self): + response = self.client.get( + reverse("audit:AuditorCertification", kwargs={"report_id": "INVALID"}) + ) + self.assertEqual(response.status_code, 403) + + def test_post_redirects_if_status_not_ready_for_certification(self): + self.sac.submission_status = STATUS.IN_PROGRESS + self.sac.save() + response = self.client.post(self.url, {"field": "value"}) + self.assertRedirects( + response, f"/audit/submission-progress/{self.sac.report_id}" + ) + + def test_post_valid_form(self): + self.session["AuditorCertificationStep1Session"] = {"field": "value"} + self.session.save() + + form_data = { + "is_OMB_limited": True, + "is_auditee_responsible": True, + "has_used_auditors_report": True, + "has_no_auditee_procedures": False, + "is_FAC_releasable": True, + "is_accurate_and_complete": True, + } + + response = self.client.post(self.url, form_data) + + self.assertEqual(response.status_code, 302) + self.sac.refresh_from_db() + + self.assertRedirects( + response, + reverse("audit:AuditorCertificationConfirm", args=[self.sac.report_id]), + ) + self.assertIn("AuditorCertificationStep1Session", self.client.session) + self.assertEqual( + self.client.session["AuditorCertificationStep1Session"], form_data + ) + + def test_post_invalid_form(self): + response = self.client.post(self.url, {"invalid_field": ""}) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/auditor-certification-step-1.html") + self.assertIn("form", response.context) + self.assertIsInstance(response.context["form"], AuditorCertificationStep1Form) + self.assertTrue(response.context["form"].errors) + + def test_post_permission_denied_if_sac_not_found(self): + response = self.client.post( + reverse("audit:AuditorCertification", kwargs={"report_id": "INVALID"}) + ) + self.assertEqual(response.status_code, 403) + + +class AuditeeCertificationStep2ViewTests(TestCase): + def setUp(self): + self.client = Client() + self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, submission_status=STATUS.AUDITOR_CERTIFIED + ) + self.url = reverse( + "audit:AuditeeCertificationConfirm", + kwargs={"report_id": self.sac.report_id}, + ) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditee_contact", + ) + self.session = self.client.session + + def test_get_redirects_if_no_step_1(self): + response = self.client.get(self.url) + self.assertRedirects( + response, reverse("audit:AuditeeCertification", args=[self.sac.report_id]) + ) + + def test_get_renders_template_if_valid_session(self): + self.session["AuditeeCertificationStep1Session"] = {"field": "value"} + self.session.save() + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/auditee-certification-step-2.html") + self.assertIn("form", response.context) + self.assertIsInstance(response.context["form"], AuditeeCertificationStep2Form) + + def test_get_redirects_if_not_auditor_certified(self): + self.sac.submission_status = STATUS.IN_PROGRESS + self.sac.save() + self.session["AuditeeCertificationStep1Session"] = {"field": "value"} + self.session.save() + response = self.client.get(self.url) + self.assertRedirects( + response, f"/audit/submission-progress/{self.sac.report_id}" + ) + + def test_redirects_if_no_step_1_session(self): + if "AuditeeCertificationStep1Session" in self.session: + del self.session["AuditeeCertificationStep1Session"] + self.session.save() + response = self.client.get(self.url, {}) + self.assertRedirects( + response, + reverse( + "audit:AuditeeCertification", kwargs={"report_id": self.sac.report_id} + ), + ) + + @patch("audit.views.views.validate_auditee_certification_json") + @patch("audit.views.views.sac_transition") + def test_post_valid_form(self, mock_transition, mock_validate): + mock_transition.return_value = True + mock_validate.return_value = {"auditee_certification": "validated_data"} + + self.session["AuditeeCertificationStep1Session"] = {"field": "value"} + self.session.save() + + self.sac.submission_status = STATUS.AUDITOR_CERTIFIED + self.sac.save() + + response = self.client.post( + self.url, + { + "auditee_certification_date_signed": "2024-01-01", + "auditee_name": "Test Auditee", + "auditee_title": "Auditor", + }, + ) + self.assertEqual(response.status_code, 302) + self.sac.refresh_from_db() + mock_transition.assert_called_once_with( + response.wsgi_request, self.sac, transition_to=STATUS.AUDITEE_CERTIFIED + ) + self.assertRedirects( + response, reverse("audit:SubmissionProgress", args=[self.sac.report_id]) + ) + + def test_post_invalid_form(self): + self.session["AuditeeCertificationStep1Session"] = None + self.session.save() + response = self.client.post(self.url, {"auditee_certification_date_signed": ""}) + + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "audit/auditee-certification-step-2.html") + self.assertIn("form", response.context) + self.assertIsInstance(response.context["form"], AuditeeCertificationStep2Form) + self.assertTrue(response.context["form"].errors) + + def test_post_redirects_if_status_not_auditor_certified(self): + self.sac.submission_status = STATUS.IN_PROGRESS + self.sac.save() + self.session["AuditeeCertificationStep1Session"] = {"field": "value"} + self.session.save() + response = self.client.post( + self.url, {"auditee_certification_date_signed": "2024-01-01"} + ) + self.assertRedirects( + response, f"/audit/submission-progress/{self.sac.report_id}" + ) + + def test_post_permission_denied_if_sac_not_found(self): + response = self.client.post( + reverse( + "audit:AuditeeCertificationConfirm", kwargs={"report_id": "INVALID"} + ) + ) + self.assertEqual(response.status_code, 403) + + def test_single_audit_checklist_does_not_exist_exception(self): + factory = RequestFactory() + request = factory.get(reverse("audit:AuditeeCertification", args=["12345"])) + + with patch("audit.models.SingleAuditChecklist.objects.get") as mock_get: + mock_get.side_effect = SingleAuditChecklist.DoesNotExist + + view = AuditeeCertificationStep2View.as_view() + + with self.assertRaises(PermissionDenied) as context: + view(request, report_id="12345") + + self.assertEqual( + str(context.exception), "You do not have access to this audit." + ) + + +class CrossValidationViewTests(TestCase): + def setUp(self): + self.client = Client() + self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, + report_id="test-report-id", + submission_status=STATUS.AUDITOR_CERTIFIED, + general_information={"auditee_fiscal_period_end": "2024-12-31"}, + ) + self.url = reverse( + "audit:CrossValidation", kwargs={"report_id": self.sac.report_id} + ) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditee_contact", + ) + + def test_get_view_renders_correct_template(self): + response = self.client.get(self.url) + + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed( + response, "audit/cross-validation/cross-validation.html" + ) + self.assertEqual(response.context["report_id"], self.sac.report_id) + self.assertEqual( + response.context["submission_status"], self.sac.submission_status + ) + + def test_get_view_permission_denied(self): + url = reverse("audit:CrossValidation", args=["non-existent-id"]) + response = self.client.get(url) + + self.assertEqual(response.status_code, 403) # PermissionDenied results in 403 + + @patch("audit.models.SingleAuditChecklist.validate_full") + def test_post_view_renders_results_template(self, mock_validate_full): + mock_validate_full.return_value = ["Error 1", "Error 2"] + + response = self.client.post(self.url) + + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed( + response, "audit/cross-validation/cross-validation-results.html" + ) + self.assertEqual(response.context["report_id"], self.sac.report_id) + self.assertEqual(response.context["errors"], ["Error 1", "Error 2"]) + mock_validate_full.assert_called_once() + + def test_post_view_permission_denied(self): + url = reverse("audit:CrossValidation", args=["non-existent-id"]) + response = self.client.post(url) + + self.assertEqual(response.status_code, 403) From 1569abdea44a70c50189631ee7e0f102037b529d Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Tue, 3 Dec 2024 16:02:05 -0700 Subject: [PATCH 02/11] updated bug in AuditorCertificationStep1ViewTests test_post_valid_form --- backend/audit/test_views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 1adab04f2..b83f365b9 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -1898,13 +1898,15 @@ def test_post_valid_form(self): "is_OMB_limited": True, "is_auditee_responsible": True, "has_used_auditors_report": True, - "has_no_auditee_procedures": False, + "has_no_auditee_procedures": True, "is_FAC_releasable": True, "is_accurate_and_complete": True, } response = self.client.post(self.url, form_data) + # print(response.content) + self.assertEqual(response.status_code, 302) self.sac.refresh_from_db() From 644e1ec2d1ca014b5f6131ff1f9e2b3ec6c56a91 Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 5 Dec 2024 08:43:45 -0700 Subject: [PATCH 03/11] Updated docstrings, removed duplicate tests --- backend/audit/test_views.py | 102 ++++++++++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 16 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index b83f365b9..9cb4c9d47 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -114,6 +114,7 @@ def _authed_post(client, user, view_str, kwargs=None, data=None): def _make_user_and_sac(**kwargs): + """Helper function for to make a user and basic sac""" user = baker.make(User) sac = baker.make(SingleAuditChecklist, **kwargs) return user, sac @@ -126,6 +127,7 @@ def _load_json(target): def _mock_gen_report_id(): + """Helper function for generate a sac report id""" return generate_sac_report_id(end_date=datetime.now().date().isoformat()) @@ -135,6 +137,7 @@ def _merge_dict_seq(seq): def _build_auditor_cert_dict(certification: dict, signature: dict) -> dict: + """Helper function for building a dictionary for auditor certification""" return { "auditor_certification": certification, "auditor_signature": signature, @@ -142,6 +145,7 @@ def _build_auditor_cert_dict(certification: dict, signature: dict) -> dict: def _build_auditee_cert_dict(certification: dict, signature: dict) -> dict: + """Helper function for building a dictionary for auditee certification""" return { "auditee_certification": certification, "auditee_signature": signature, @@ -218,21 +222,25 @@ def test_no_robots(self): class MySubmissionsViewTests(TestCase): def setUp(self): + """Setup function for users and client""" self.user = baker.make(User) self.user2 = baker.make(User) self.client = Client() def test_redirect_if_not_logged_in(self): + """Test that accessing submission page redirects if user is not logged in""" result = self.client.get(SUBMISSIONS_PATH) self.assertAlmostEqual(result.status_code, 302) def test_no_submissions_returns_empty_list(self): + """Test that an authenticated user with no submissions gets empty list""" self.client.force_login(user=self.user) data = MySubmissions.fetch_my_submissions(self.user) self.assertEqual(len(data), 0) def test_user_with_submissions_should_return_expected_data_columns(self): + """Test that a user with submissions gets data with expected columns""" self.client.force_login(user=self.user) self.user.profile.entry_form_data = ( VALID_ELIGIBILITY_DATA | VALID_AUDITEE_INFO_DATA @@ -252,6 +260,7 @@ def test_user_with_submissions_should_return_expected_data_columns(self): self.assertTrue("fiscal_year_end_date" in keys) def test_user_with_no_submissions_should_return_no_data(self): + """Test that another user with no submissions gets no data""" self.client.force_login(user=self.user) self.user.profile.entry_form_data = ( VALID_ELIGIBILITY_DATA | VALID_AUDITEE_INFO_DATA @@ -266,20 +275,40 @@ def test_user_with_no_submissions_should_return_no_data(self): class EditSubmissionViewTests(TestCase): def setUp(self): + """Setup test factory, client, user, and report ID""" + self.factory = RequestFactory() self.client = Client() self.user = baker.make(User) + self.sac = baker.make( + SingleAuditChecklist, submission_status=STATUS.READY_FOR_CERTIFICATION + ) self.url_name = "audit:EditSubmission" self.report_id = "TEST_REPORT_ID" - - def test_redirect_if_not_logged_in(self): - result = self.client.get(reverse(EDIT_PATH, args=["SOME_REPORT_ID"])) - self.assertAlmostEqual(result.status_code, 302) + self.url = reverse( + "audit:EditSubmission", kwargs={"report_id": self.sac.report_id} + ) + self.client.force_login(self.user) + baker.make( + "audit.Access", + sac=self.sac, + user=self.user, + role="certifying_auditee_contact", + ) + self.session = self.client.session def test_redirect_not_logged_in(self): + """Test that accessing edit submission page redirects if not authenticated""" url = reverse(self.url_name, args=[self.report_id]) response = self.client.get(url) self.assertEqual(response.status_code, 302) + def test_redirects_to_singleauditchecklist(self): + """Test that accessing edit submission redirects to SAC view""" + response = self.client.get(self.url) + self.assertRedirects( + response, reverse("singleauditchecklist", args=[self.sac.report_id]) + ) + class SubmissionViewTests(TestCase): """ @@ -287,6 +316,7 @@ class SubmissionViewTests(TestCase): """ def setUp(self): + """Set up test client, user, SAC, and URL""" self.client = Client() self.user = baker.make(User) self.sac = baker.make( @@ -302,6 +332,7 @@ def setUp(self): ) def test_get_renders_template(self): + """Test that GET renders the submission template with correct context""" response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "audit/submission.html") @@ -313,11 +344,13 @@ def test_get_renders_template(self): ) def test_get_permission_denied_if_no_sac(self): + """Test that GET returns 403 if SAC does not exist""" invalid_url = reverse("audit:Submission", kwargs={"report_id": "INVALID"}) response = self.client.get(invalid_url) self.assertEqual(response.status_code, 403) def test_get_access_denied_for_unauthorized_user(self): + """Test that GET returns 403 if user is unauthorized""" self.client.logout() response = self.client.get(self.url) self.assertEqual(response.status_code, 403) @@ -329,6 +362,7 @@ def test_get_access_denied_for_unauthorized_user(self): def test_post_valid_submission( self, mock_disseminate, mock_remove, mock_transition, mock_validate ): + """Test that a valid submission transitions SAC to a disseminated state""" mock_validate.return_value = [] mock_disseminate.return_value = None @@ -351,6 +385,7 @@ def test_post_valid_submission( def test_post_validation_errors( self, mock_disseminate, mock_transition, mock_validate ): + """Test that validation errors are displayed if submission is invalid""" mock_validate.return_value = ["Error 1", "Error 2"] response = self.client.post(self.url) @@ -367,6 +402,7 @@ def test_post_validation_errors( @patch("audit.views.views.General.objects.get") @patch("audit.views.views.SingleAuditChecklist.validate_full") def test_post_transaction_error(self, mock_validate, mock_general_get): + """Test that a transaction error during a submission is handled properly""" self.sac.submission_status = STATUS.AUDITEE_CERTIFIED self.sac.save() @@ -383,6 +419,7 @@ def test_post_transaction_error(self, mock_validate, mock_general_get): self.assertRedirects(response, reverse("audit:MySubmissions")) def test_post_permission_denied_if_no_sac(self): + """Test that POST returns 403 if SAC does not exist""" invalid_url = reverse("audit:Submission", kwargs={"report_id": "INVALID"}) response = self.client.post(invalid_url) self.assertEqual(response.status_code, 403) @@ -445,11 +482,13 @@ def test_post_redirect(self): class SubmissionGetTest(TestCase): def setUp(self): + """Setup test user and client""" self.user = baker.make(User) self.client = Client() self.url = reverse("audit:MySubmissions") def testValidSubmission(self): + """Test that a valid submission is displayed on the submissions page""" self.client.force_login(self.user) sac1 = baker.make(SingleAuditChecklist, submission_status=STATUS.IN_PROGRESS) sac2 = baker.make(SingleAuditChecklist, submission_status=STATUS.DISSEMINATED) @@ -473,6 +512,7 @@ class SubmissionStatusTests(TransactionTestCase): """ def setUp(self): + """Setup user and client""" self.user = baker.make(User) self.client = Client() @@ -1480,6 +1520,7 @@ def test_late_file_upload(self, mock_scan_file): ) def test_get_login_required(self): + """Test that uploading files requires user authentication""" for form_section in FORM_SECTIONS: response = self.client.get( reverse( @@ -1490,6 +1531,7 @@ def test_get_login_required(self): self.assertEqual(response.status_code, 403) def test_get_bad_report_id_returns_403(self): + """Test that uploading with a malformed or nonexistant report_id reutrns 403""" user = baker.make(User) self.client.force_login(user) @@ -1568,6 +1610,7 @@ def test_no_file_attached_returns_400(self): @patch("audit.validators._scan_file") def test_valid_file_upload(self, mock_scan_file): + """Test that uploading a valid SAR update the SAC accordingly""" sac = _mock_login_and_scan( self.client, mock_scan_file, @@ -1817,6 +1860,7 @@ def test_valid_file_upload_for_notes_to_sefa(self, mock_scan_file): class EditSubmissionTest(TestCase): def setUp(self): + """Setup factory, client, user, SAC, and URL""" self.factory = RequestFactory() self.client = Client() self.user = baker.make(User) @@ -1836,6 +1880,7 @@ def setUp(self): self.session = self.client.session def test_redirects_to_singleauditchecklist(self): + """Test that accessing edit submission redirects to SAC view""" response = self.client.get(self.url) self.assertRedirects( response, reverse("singleauditchecklist", args=[self.sac.report_id]) @@ -1844,6 +1889,7 @@ def test_redirects_to_singleauditchecklist(self): class AuditorCertificationStep1ViewTests(TestCase): def setUp(self): + """Setup client, user, SAC, and URL""" self.client = Client() self.user = baker.make(User) self.sac = baker.make( @@ -1862,6 +1908,7 @@ def setUp(self): self.session = self.client.session def test_get_redirects_if_status_not_ready_for_certification(self): + """Test that GET redirects if SAC status is not READY_FOR_CERTIFICATION""" self.sac.submission_status = STATUS.IN_PROGRESS self.sac.save() response = self.client.get(self.url) @@ -1870,6 +1917,10 @@ def test_get_redirects_if_status_not_ready_for_certification(self): ) def test_get_renders_template_if_valid_state(self): + """ + Test that GET renders the auditor certification setp 1 template when SAC + is in a valid state. + """ response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "audit/auditor-certification-step-1.html") @@ -1877,12 +1928,14 @@ def test_get_renders_template_if_valid_state(self): self.assertIsInstance(response.context["form"], AuditorCertificationStep1Form) def test_get_permission_denied_if_sac_not_found(self): + """Test that POST redirects if SAC report_id is not found""" response = self.client.get( reverse("audit:AuditorCertification", kwargs={"report_id": "INVALID"}) ) self.assertEqual(response.status_code, 403) def test_post_redirects_if_status_not_ready_for_certification(self): + """Test that POST redirects if SAC status is not READY_FOR_CERTIFICATION""" self.sac.submission_status = STATUS.IN_PROGRESS self.sac.save() response = self.client.post(self.url, {"field": "value"}) @@ -1891,6 +1944,10 @@ def test_post_redirects_if_status_not_ready_for_certification(self): ) def test_post_valid_form(self): + """ + Test that submitting a valid form updates the session + and redirects correctly + """ self.session["AuditorCertificationStep1Session"] = {"field": "value"} self.session.save() @@ -1920,6 +1977,7 @@ def test_post_valid_form(self): ) def test_post_invalid_form(self): + """Test that submitting and invalid form renders an error template""" response = self.client.post(self.url, {"invalid_field": ""}) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "audit/auditor-certification-step-1.html") @@ -1928,6 +1986,7 @@ def test_post_invalid_form(self): self.assertTrue(response.context["form"].errors) def test_post_permission_denied_if_sac_not_found(self): + """Test that results in 403 if SAC report_id is not found""" response = self.client.post( reverse("audit:AuditorCertification", kwargs={"report_id": "INVALID"}) ) @@ -1936,6 +1995,7 @@ def test_post_permission_denied_if_sac_not_found(self): class AuditeeCertificationStep2ViewTests(TestCase): def setUp(self): + """Setup client, user, SAC, and URL""" self.client = Client() self.user = baker.make(User) self.sac = baker.make( @@ -1955,12 +2015,17 @@ def setUp(self): self.session = self.client.session def test_get_redirects_if_no_step_1(self): + """Test that GET redirects if AuditeeCertificationStep1Session is missing""" response = self.client.get(self.url) self.assertRedirects( response, reverse("audit:AuditeeCertification", args=[self.sac.report_id]) ) def test_get_renders_template_if_valid_session(self): + """ + Test that GET renders the Auditee certification step 2 + if session is valid + """ self.session["AuditeeCertificationStep1Session"] = {"field": "value"} self.session.save() response = self.client.get(self.url) @@ -1970,6 +2035,7 @@ def test_get_renders_template_if_valid_session(self): self.assertIsInstance(response.context["form"], AuditeeCertificationStep2Form) def test_get_redirects_if_not_auditor_certified(self): + """Test that GET will redirect if SAC status is not AUDITOR_CERTIFIED""" self.sac.submission_status = STATUS.IN_PROGRESS self.sac.save() self.session["AuditeeCertificationStep1Session"] = {"field": "value"} @@ -1979,21 +2045,13 @@ def test_get_redirects_if_not_auditor_certified(self): response, f"/audit/submission-progress/{self.sac.report_id}" ) - def test_redirects_if_no_step_1_session(self): - if "AuditeeCertificationStep1Session" in self.session: - del self.session["AuditeeCertificationStep1Session"] - self.session.save() - response = self.client.get(self.url, {}) - self.assertRedirects( - response, - reverse( - "audit:AuditeeCertification", kwargs={"report_id": self.sac.report_id} - ), - ) - @patch("audit.views.views.validate_auditee_certification_json") @patch("audit.views.views.sac_transition") def test_post_valid_form(self, mock_transition, mock_validate): + """ + Test that submitting a valid Auditee Certification Form + updates the SAC and redirects correctly + """ mock_transition.return_value = True mock_validate.return_value = {"auditee_certification": "validated_data"} @@ -2021,6 +2079,10 @@ def test_post_valid_form(self, mock_transition, mock_validate): ) def test_post_invalid_form(self): + """ + Test that submitting an invalid Auditee Ceritifcation Form + renders an error template + """ self.session["AuditeeCertificationStep1Session"] = None self.session.save() response = self.client.post(self.url, {"auditee_certification_date_signed": ""}) @@ -2032,6 +2094,7 @@ def test_post_invalid_form(self): self.assertTrue(response.context["form"].errors) def test_post_redirects_if_status_not_auditor_certified(self): + """Test that POST will redirect if SAC submission status is not AUDITOR_CERTIFIED""" self.sac.submission_status = STATUS.IN_PROGRESS self.sac.save() self.session["AuditeeCertificationStep1Session"] = {"field": "value"} @@ -2044,6 +2107,7 @@ def test_post_redirects_if_status_not_auditor_certified(self): ) def test_post_permission_denied_if_sac_not_found(self): + """Test that POST will result in permission error is SAC report_id not found""" response = self.client.post( reverse( "audit:AuditeeCertificationConfirm", kwargs={"report_id": "INVALID"} @@ -2052,6 +2116,7 @@ def test_post_permission_denied_if_sac_not_found(self): self.assertEqual(response.status_code, 403) def test_single_audit_checklist_does_not_exist_exception(self): + """Test that SAC does not exist renders a unique exception.""" factory = RequestFactory() request = factory.get(reverse("audit:AuditeeCertification", args=["12345"])) @@ -2070,6 +2135,7 @@ def test_single_audit_checklist_does_not_exist_exception(self): class CrossValidationViewTests(TestCase): def setUp(self): + """Setup client, user, SAC, and URL""" self.client = Client() self.user = baker.make(User) self.sac = baker.make( @@ -2090,6 +2156,7 @@ def setUp(self): ) def test_get_view_renders_correct_template(self): + """Test that GET renders cross-validation template with correct context""" response = self.client.get(self.url) self.assertEqual(response.status_code, 200) @@ -2102,6 +2169,7 @@ def test_get_view_renders_correct_template(self): ) def test_get_view_permission_denied(self): + """Test that GET returns 403 if SAC report_id does not exist""" url = reverse("audit:CrossValidation", args=["non-existent-id"]) response = self.client.get(url) @@ -2109,6 +2177,7 @@ def test_get_view_permission_denied(self): @patch("audit.models.SingleAuditChecklist.validate_full") def test_post_view_renders_results_template(self, mock_validate_full): + """Test that POST with validation errors renders template with errors""" mock_validate_full.return_value = ["Error 1", "Error 2"] response = self.client.post(self.url) @@ -2122,6 +2191,7 @@ def test_post_view_renders_results_template(self, mock_validate_full): mock_validate_full.assert_called_once() def test_post_view_permission_denied(self): + """Test that POST returns 403 if SAC report_id does not exist""" url = reverse("audit:CrossValidation", args=["non-existent-id"]) response = self.client.post(url) From 39da46ab7f43c4564910dbcaea28ab0b3ba057ce Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 5 Dec 2024 08:45:07 -0700 Subject: [PATCH 04/11] Updated format --- backend/audit/test_views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 9cb4c9d47..9729c2e56 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -1945,7 +1945,7 @@ def test_post_redirects_if_status_not_ready_for_certification(self): def test_post_valid_form(self): """ - Test that submitting a valid form updates the session + Test that submitting a valid form updates the session and redirects correctly """ self.session["AuditorCertificationStep1Session"] = {"field": "value"} @@ -2023,7 +2023,7 @@ def test_get_redirects_if_no_step_1(self): def test_get_renders_template_if_valid_session(self): """ - Test that GET renders the Auditee certification step 2 + Test that GET renders the Auditee certification step 2 if session is valid """ self.session["AuditeeCertificationStep1Session"] = {"field": "value"} @@ -2049,7 +2049,7 @@ def test_get_redirects_if_not_auditor_certified(self): @patch("audit.views.views.sac_transition") def test_post_valid_form(self, mock_transition, mock_validate): """ - Test that submitting a valid Auditee Certification Form + Test that submitting a valid Auditee Certification Form updates the SAC and redirects correctly """ mock_transition.return_value = True @@ -2080,7 +2080,7 @@ def test_post_valid_form(self, mock_transition, mock_validate): def test_post_invalid_form(self): """ - Test that submitting an invalid Auditee Ceritifcation Form + Test that submitting an invalid Auditee Ceritifcation Form renders an error template """ self.session["AuditeeCertificationStep1Session"] = None From 9dcbe15df78b01ad0a64ede993d88b556e0e41db Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 5 Dec 2024 14:57:24 -0700 Subject: [PATCH 05/11] Removed print statements --- backend/audit/test_views.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 9729c2e56..6de0c80af 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -414,7 +414,6 @@ def test_post_transaction_error(self, mock_validate, mock_general_get): self.assertEqual(response.status_code, 302) self.assertRedirects(response, reverse("audit:MySubmissions")) - print("this response", response) self.assertEqual(response.status_code, 302) self.assertRedirects(response, reverse("audit:MySubmissions")) @@ -1962,8 +1961,6 @@ def test_post_valid_form(self): response = self.client.post(self.url, form_data) - # print(response.content) - self.assertEqual(response.status_code, 302) self.sac.refresh_from_db() From f2ebc9caf85c38a6bba95aa2b36ff4a832737b29 Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Fri, 6 Dec 2024 10:02:34 -0700 Subject: [PATCH 06/11] Updated status code for new verify function --- backend/audit/test_views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 6de0c80af..073f35af2 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -388,6 +388,9 @@ def test_post_validation_errors( """Test that validation errors are displayed if submission is invalid""" mock_validate.return_value = ["Error 1", "Error 2"] + self.sac.submission_status = STATUS.AUDITEE_CERTIFIED + self.sac.save() + response = self.client.post(self.url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed( From b36b7ff60cb683d3f70b28397776206bc7b367ec Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 12 Dec 2024 12:03:30 -0700 Subject: [PATCH 07/11] Updated test logic for SubmissionViewTests --- backend/audit/test_views.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 073f35af2..136df058f 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -320,7 +320,7 @@ def setUp(self): self.client = Client() self.user = baker.make(User) self.sac = baker.make( - SingleAuditChecklist, submission_status=STATUS.READY_FOR_CERTIFICATION + SingleAuditChecklist, submission_status=STATUS.AUDITEE_CERTIFIED ) self.url = reverse("audit:Submission", kwargs={"report_id": self.sac.report_id}) self.client.force_login(self.user) @@ -355,29 +355,26 @@ def test_get_access_denied_for_unauthorized_user(self): response = self.client.get(self.url) self.assertEqual(response.status_code, 403) - @patch("audit.views.views.SingleAuditChecklist.validate_full") + @patch("audit.models.SingleAuditChecklist.validate_full") @patch("audit.views.views.sac_transition") @patch("audit.views.views.remove_workbook_artifacts") @patch("audit.views.views.SingleAuditChecklist.disseminate") - def test_post_valid_submission( - self, mock_disseminate, mock_remove, mock_transition, mock_validate - ): + def test_post_successful(self, mock_disseminate, mock_remove, mock_transition, mock_validate): """Test that a valid submission transitions SAC to a disseminated state""" mock_validate.return_value = [] mock_disseminate.return_value = None - response = self.client.post(self.url) + + mock_validate.assert_called_once() + mock_disseminate.assert_called_once() + mock_transition.assert_called_with( + response.wsgi_request, self.sac, transition_to=STATUS.DISSEMINATED + ) + mock_remove.assert_called_once() + self.assertEqual(response.status_code, 302) self.assertRedirects(response, reverse("audit:MySubmissions")) - mock_transition.assert_any_call( - response.wsgi_request, self.sac, transition_to=STATUS.SUBMITTED - ) - mock_transition.assert_any_call( - response.wsgi_request, self.sac, transition_to=STATUS.DISSEMINATED - ) - mock_disseminate.assert_called_once() - mock_remove.assert_called_once_with(self.sac) @patch("audit.views.views.SingleAuditChecklist.validate_full") @patch("audit.views.views.sac_transition") From 4961bfc16c8d7573e9a6f9c5af981a4915499c82 Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 12 Dec 2024 12:08:02 -0700 Subject: [PATCH 08/11] Updated formatting/linting --- backend/audit/test_views.py | 60 ++++++++++++++----------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index 136df058f..eb653669f 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -5,40 +5,25 @@ from unittest.mock import patch from audit.cross_validation.naming import SECTION_NAMES as SN -from audit.fixtures.excel import ( - ADDITIONAL_EINS_ENTRY_FIXTURES, - ADDITIONAL_EINS_TEMPLATE, - ADDITIONAL_UEIS_ENTRY_FIXTURES, - ADDITIONAL_UEIS_TEMPLATE, - CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, - CORRECTIVE_ACTION_PLAN_TEMPLATE, - FEDERAL_AWARDS_ENTRY_FIXTURES, - FEDERAL_AWARDS_TEMPLATE, - FINDINGS_TEXT_ENTRY_FIXTURES, - FINDINGS_TEXT_TEMPLATE, - FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, - FINDINGS_UNIFORM_GUIDANCE_TEMPLATE, - FORM_SECTIONS, - NOTES_TO_SEFA_ENTRY_FIXTURES, - NOTES_TO_SEFA_TEMPLATE, - SECONDARY_AUDITORS_ENTRY_FIXTURES, - SECONDARY_AUDITORS_TEMPLATE, -) -from audit.fixtures.single_audit_checklist import ( - fake_auditee_certification, - fake_auditor_certification, -) -from audit.forms import ( - AuditeeCertificationStep2Form, - AuditorCertificationStep1Form, -) -from audit.models import ( - Access, - SingleAuditChecklist, - SingleAuditReportFile, - SubmissionEvent, - generate_sac_report_id, -) +from audit.fixtures.excel import (ADDITIONAL_EINS_ENTRY_FIXTURES, + ADDITIONAL_EINS_TEMPLATE, + ADDITIONAL_UEIS_ENTRY_FIXTURES, + ADDITIONAL_UEIS_TEMPLATE, + CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, + CORRECTIVE_ACTION_PLAN_TEMPLATE, + FEDERAL_AWARDS_ENTRY_FIXTURES, + FEDERAL_AWARDS_TEMPLATE, FINDINGS_TEXT_ENTRY_FIXTURES, + FINDINGS_TEXT_TEMPLATE, + FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, + FINDINGS_UNIFORM_GUIDANCE_TEMPLATE, FORM_SECTIONS, + NOTES_TO_SEFA_ENTRY_FIXTURES, NOTES_TO_SEFA_TEMPLATE, + SECONDARY_AUDITORS_ENTRY_FIXTURES, + SECONDARY_AUDITORS_TEMPLATE) +from audit.fixtures.single_audit_checklist import (fake_auditee_certification, + fake_auditor_certification) +from audit.forms import AuditeeCertificationStep2Form, AuditorCertificationStep1Form +from audit.models import (Access, SingleAuditChecklist, SingleAuditReportFile, + SubmissionEvent, generate_sac_report_id) from audit.models.models import STATUS from audit.views import AuditeeCertificationStep2View, MySubmissions from dissemination.models import FederalAward, General @@ -359,12 +344,14 @@ def test_get_access_denied_for_unauthorized_user(self): @patch("audit.views.views.sac_transition") @patch("audit.views.views.remove_workbook_artifacts") @patch("audit.views.views.SingleAuditChecklist.disseminate") - def test_post_successful(self, mock_disseminate, mock_remove, mock_transition, mock_validate): + def test_post_successful( + self, mock_disseminate, mock_remove, mock_transition, mock_validate + ): """Test that a valid submission transitions SAC to a disseminated state""" mock_validate.return_value = [] mock_disseminate.return_value = None response = self.client.post(self.url) - + mock_validate.assert_called_once() mock_disseminate.assert_called_once() mock_transition.assert_called_with( @@ -375,7 +362,6 @@ def test_post_successful(self, mock_disseminate, mock_remove, mock_transition, m self.assertEqual(response.status_code, 302) self.assertRedirects(response, reverse("audit:MySubmissions")) - @patch("audit.views.views.SingleAuditChecklist.validate_full") @patch("audit.views.views.sac_transition") @patch("audit.views.views.SingleAuditChecklist.disseminate") From 51872bc9bdda58cf3015bd02c3f53ca6650bfcaa Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 12 Dec 2024 12:11:25 -0700 Subject: [PATCH 09/11] black format update --- backend/audit/test_views.py | 48 +++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index eb653669f..ddbcb1672 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -5,25 +5,37 @@ from unittest.mock import patch from audit.cross_validation.naming import SECTION_NAMES as SN -from audit.fixtures.excel import (ADDITIONAL_EINS_ENTRY_FIXTURES, - ADDITIONAL_EINS_TEMPLATE, - ADDITIONAL_UEIS_ENTRY_FIXTURES, - ADDITIONAL_UEIS_TEMPLATE, - CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, - CORRECTIVE_ACTION_PLAN_TEMPLATE, - FEDERAL_AWARDS_ENTRY_FIXTURES, - FEDERAL_AWARDS_TEMPLATE, FINDINGS_TEXT_ENTRY_FIXTURES, - FINDINGS_TEXT_TEMPLATE, - FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, - FINDINGS_UNIFORM_GUIDANCE_TEMPLATE, FORM_SECTIONS, - NOTES_TO_SEFA_ENTRY_FIXTURES, NOTES_TO_SEFA_TEMPLATE, - SECONDARY_AUDITORS_ENTRY_FIXTURES, - SECONDARY_AUDITORS_TEMPLATE) -from audit.fixtures.single_audit_checklist import (fake_auditee_certification, - fake_auditor_certification) +from audit.fixtures.excel import ( + ADDITIONAL_EINS_ENTRY_FIXTURES, + ADDITIONAL_EINS_TEMPLATE, + ADDITIONAL_UEIS_ENTRY_FIXTURES, + ADDITIONAL_UEIS_TEMPLATE, + CORRECTIVE_ACTION_PLAN_ENTRY_FIXTURES, + CORRECTIVE_ACTION_PLAN_TEMPLATE, + FEDERAL_AWARDS_ENTRY_FIXTURES, + FEDERAL_AWARDS_TEMPLATE, + FINDINGS_TEXT_ENTRY_FIXTURES, + FINDINGS_TEXT_TEMPLATE, + FINDINGS_UNIFORM_GUIDANCE_ENTRY_FIXTURES, + FINDINGS_UNIFORM_GUIDANCE_TEMPLATE, + FORM_SECTIONS, + NOTES_TO_SEFA_ENTRY_FIXTURES, + NOTES_TO_SEFA_TEMPLATE, + SECONDARY_AUDITORS_ENTRY_FIXTURES, + SECONDARY_AUDITORS_TEMPLATE, +) +from audit.fixtures.single_audit_checklist import ( + fake_auditee_certification, + fake_auditor_certification, +) from audit.forms import AuditeeCertificationStep2Form, AuditorCertificationStep1Form -from audit.models import (Access, SingleAuditChecklist, SingleAuditReportFile, - SubmissionEvent, generate_sac_report_id) +from audit.models import ( + Access, + SingleAuditChecklist, + SingleAuditReportFile, + SubmissionEvent, + generate_sac_report_id, +) from audit.models.models import STATUS from audit.views import AuditeeCertificationStep2View, MySubmissions from dissemination.models import FederalAward, General From 7e8170148a68379f19a49afab748298df53c999b Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 12 Dec 2024 16:18:15 -0700 Subject: [PATCH 10/11] Updated format of docstring --- backend/audit/test_views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index ddbcb1672..ab759819d 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -359,7 +359,8 @@ def test_get_access_denied_for_unauthorized_user(self): def test_post_successful( self, mock_disseminate, mock_remove, mock_transition, mock_validate ): - """Test that a valid submission transitions SAC to a disseminated state""" + """Test that a valid submission transitions + SAC to a disseminated state""" mock_validate.return_value = [] mock_disseminate.return_value = None response = self.client.post(self.url) From a2651cd8db986d5ff25b1b6fb7ef9561c277e6d4 Mon Sep 17 00:00:00 2001 From: Anastasia Gradova Date: Thu, 12 Dec 2024 16:20:56 -0700 Subject: [PATCH 11/11] re-fixed docstring --- backend/audit/test_views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/audit/test_views.py b/backend/audit/test_views.py index ab759819d..ddbcb1672 100644 --- a/backend/audit/test_views.py +++ b/backend/audit/test_views.py @@ -359,8 +359,7 @@ def test_get_access_denied_for_unauthorized_user(self): def test_post_successful( self, mock_disseminate, mock_remove, mock_transition, mock_validate ): - """Test that a valid submission transitions - SAC to a disseminated state""" + """Test that a valid submission transitions SAC to a disseminated state""" mock_validate.return_value = [] mock_disseminate.return_value = None response = self.client.post(self.url)