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,
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()

View file

@ -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)