Re-fix unit test

This commit is contained in:
zandercymatics 2024-06-11 09:29:32 -06:00
parent fc93415560
commit 822829da47
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 21 additions and 14 deletions

View file

@ -742,10 +742,14 @@ class MockDb(TestCase):
status=DomainRequest.DomainRequestStatus.APPROVED, status=DomainRequest.DomainRequestStatus.APPROVED,
name="city5.gov", 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_3.submit()
self.domain_request_4.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( other, _ = Contact.objects.get_or_create(
first_name="Testy1232", first_name="Testy1232",
last_name="Tester24", last_name="Tester24",
@ -764,20 +768,20 @@ class MockDb(TestCase):
website_2, _ = Website.objects.get_or_create(website="cheeseville.gov") website_2, _ = Website.objects.get_or_create(website="cheeseville.gov")
website_3, _ = Website.objects.get_or_create(website="https://www.example.com") website_3, _ = Website.objects.get_or_create(website="https://www.example.com")
website_4, _ = Website.objects.get_or_create(website="https://www.example2.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, other_2)
self.domain_request_3.other_contacts.add(other_2) self.domain_request_3.alternative_domains.add(website, website_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.current_websites.add(website_3, website_4) 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.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_3.save()
self.domain_request_4.submission_date = get_time_aware_date(datetime(2024, 4, 2)) self.domain_request_4.submission_date = get_time_aware_date(datetime(2024, 4, 2))
self.domain_request_4.save() 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): def tearDown(self):
super().tearDown() super().tearDown()
PublicContact.objects.all().delete() PublicContact.objects.all().delete()

View file

@ -672,6 +672,7 @@ class ExportDataTest(MockDb, MockEppLib):
columns = [ columns = [
"Domain request", "Domain request",
"Domain type", "Domain type",
"Federal type"
] ]
sort_fields = [ sort_fields = [
"requested_domain__name", "requested_domain__name",
@ -696,7 +697,7 @@ class ExportDataTest(MockDb, MockEppLib):
expected_content = ( expected_content = (
"Domain request,Domain type,Federal type\n" "Domain request,Domain type,Federal type\n"
"city3.gov,Federal,Executive\n" "city3.gov,Federal,Executive\n"
"city4.gov,Federal,Executive\n" "city6.gov,Federal,Executive\n"
) )
# Normalize line endings and remove commas, # Normalize line endings and remove commas,
@ -708,7 +709,7 @@ class ExportDataTest(MockDb, MockEppLib):
@less_console_noise_decorator @less_console_noise_decorator
def test_full_domain_request_report(self): def test_full_domain_request_report(self):
""" """ """Tests the full domain request report."""
# Create a CSV file in memory # Create a CSV file in memory
csv_file = StringIO() csv_file = StringIO()
@ -737,7 +738,7 @@ class ExportDataTest(MockDb, MockEppLib):
csv_file.seek(0) csv_file.seek(0)
# Read the content into a variable # Read the content into a variable
csv_content = csv_file.read() csv_content = csv_file.read()
print(csv_content)
expected_content = ( expected_content = (
# Header # Header
"Domain request,Submitted at,Status,Domain type,Federal type," "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" " https://www.example2.com | https://www.example.com,\n"
"city5.gov,,Approved,Federal,Executive,,Testorg,N/A,,NY,2,,,,1,0," "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 " "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, # Normalize line endings and remove commas,
@ -809,5 +812,5 @@ class HelperFunctions(MockDb):
"submission_date__lte": self.end_date, "submission_date__lte": self.end_date,
} }
submitted_requests_sliced_at_end_date = get_sliced_requests(filter_condition) 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) self.assertEqual(submitted_requests_sliced_at_end_date, expected_content)

View file

@ -816,7 +816,7 @@ class DomainRequestExport:
# Annotations are custom columns returned to the queryset (AKA: computed in the DB). # Annotations are custom columns returned to the queryset (AKA: computed in the DB).
annotations = cls._full_domain_request_annotations() 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. # (just returns the field id of say, "creator") - so we have to include this.
additional_values = [ additional_values = [
"requested_domain__name", "requested_domain__name",