From 822829da47b11cb2c29414c81896897a9a503167 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:29:32 -0600 Subject: [PATCH] Re-fix unit test --- src/registrar/tests/common.py | 20 ++++++++++++-------- src/registrar/tests/test_reports.py | 13 ++++++++----- src/registrar/utility/csv_export.py | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index 4dce716b6..1d52b9bf2 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -742,10 +742,14 @@ class MockDb(TestCase): status=DomainRequest.DomainRequestStatus.APPROVED, name="city5.gov", ) + self.domain_request_6 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.STARTED, + name="city6.gov", + ) self.domain_request_3.submit() self.domain_request_4.submit() + self.domain_request_6.submit() - self.domain_request_3.submission_date = get_time_aware_date(datetime(2024, 4, 2)) other, _ = Contact.objects.get_or_create( first_name="Testy1232", last_name="Tester24", @@ -764,20 +768,20 @@ class MockDb(TestCase): website_2, _ = Website.objects.get_or_create(website="cheeseville.gov") website_3, _ = Website.objects.get_or_create(website="https://www.example.com") website_4, _ = Website.objects.get_or_create(website="https://www.example2.com") - self.domain_request_3.other_contacts.add(other) - self.domain_request_3.save() - self.domain_request_3.other_contacts.add(other_2) - self.domain_request_3.save() - self.domain_request_3.alternative_domains.add(website) - self.domain_request_3.alternative_domains.add(website_2) + + self.domain_request_3.other_contacts.add(other, other_2) + self.domain_request_3.alternative_domains.add(website, website_2) self.domain_request_3.current_websites.add(website_3, website_4) - self.domain_request_3.current_websites.add(website_4) self.domain_request_3.cisa_representative_email = "test@igorville.com" + self.domain_request_3.submission_date = get_time_aware_date(datetime(2024, 4, 2)) self.domain_request_3.save() self.domain_request_4.submission_date = get_time_aware_date(datetime(2024, 4, 2)) self.domain_request_4.save() + self.domain_request_6.submission_date = get_time_aware_date(datetime(2024, 4, 2)) + self.domain_request_6.save() + def tearDown(self): super().tearDown() PublicContact.objects.all().delete() diff --git a/src/registrar/tests/test_reports.py b/src/registrar/tests/test_reports.py index 1c0b64803..4522fbae1 100644 --- a/src/registrar/tests/test_reports.py +++ b/src/registrar/tests/test_reports.py @@ -672,6 +672,7 @@ class ExportDataTest(MockDb, MockEppLib): columns = [ "Domain request", "Domain type", + "Federal type" ] sort_fields = [ "requested_domain__name", @@ -696,7 +697,7 @@ class ExportDataTest(MockDb, MockEppLib): expected_content = ( "Domain request,Domain type,Federal type\n" "city3.gov,Federal,Executive\n" - "city4.gov,Federal,Executive\n" + "city6.gov,Federal,Executive\n" ) # Normalize line endings and remove commas, @@ -708,7 +709,7 @@ class ExportDataTest(MockDb, MockEppLib): @less_console_noise_decorator def test_full_domain_request_report(self): - """ """ + """Tests the full domain request report.""" # Create a CSV file in memory csv_file = StringIO() @@ -737,7 +738,7 @@ class ExportDataTest(MockDb, MockEppLib): csv_file.seek(0) # Read the content into a variable csv_content = csv_file.read() - print(csv_content) + expected_content = ( # Header "Domain request,Submitted at,Status,Domain type,Federal type," @@ -757,7 +758,9 @@ class ExportDataTest(MockDb, MockEppLib): " https://www.example2.com | https://www.example.com,\n" "city5.gov,,Approved,Federal,Executive,,Testorg,N/A,,NY,2,,,,1,0," "city1.gov,Testy,Tester,testy@town.com,Chief Tester,Purpose of the site,There " - "is more,Testy Tester testy2@town.com,,city.com," + "is more,Testy Tester testy2@town.com,,city.com,\n" + "city6.gov,2024-04-02,Submitted,Federal,Executive,,Testorg,N/A,,NY,2,,,,0,1,city1.gov,Testy,Tester," + "testy@town.com,Chief Tester,Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com," ) # Normalize line endings and remove commas, @@ -809,5 +812,5 @@ class HelperFunctions(MockDb): "submission_date__lte": self.end_date, } submitted_requests_sliced_at_end_date = get_sliced_requests(filter_condition) - expected_content = [2, 2, 0, 0, 0, 0, 0, 0, 0, 0] + expected_content = [2, 2, 0, 0, 0, 0, 0, 0, 0, 1] self.assertEqual(submitted_requests_sliced_at_end_date, expected_content) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 7ffca46e3..dc5910b7f 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -816,7 +816,7 @@ class DomainRequestExport: # Annotations are custom columns returned to the queryset (AKA: computed in the DB). annotations = cls._full_domain_request_annotations() - # The .values returned from annotate_and_retrieve_fields can't go two levels deep + # The .values returned from annotate_and_retrieve_fields can't go two levels deep # (just returns the field id of say, "creator") - so we have to include this. additional_values = [ "requested_domain__name",