firx readt_at in unit tests

This commit is contained in:
Rachid Mrad 2023-12-21 15:11:31 -05:00
parent 92f17c437f
commit fff9873998
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF
2 changed files with 9 additions and 9 deletions

View file

@ -233,7 +233,7 @@ class ExportDataTest(TestCase):
)
self.domain_1, _ = Domain.objects.get_or_create(
name="cdomain1.gov", state=Domain.State.READY, ready_at=timezone.now()
name="cdomain1.gov", state=Domain.State.READY, first_ready_at=timezone.now()
)
self.domain_2, _ = Domain.objects.get_or_create(name="adomain2.gov", state=Domain.State.DNS_NEEDED)
self.domain_3, _ = Domain.objects.get_or_create(name="ddomain3.gov", state=Domain.State.ON_HOLD)
@ -263,7 +263,7 @@ class ExportDataTest(TestCase):
self.domain_10, _ = Domain.objects.get_or_create(
name="adomain10.gov",
state=Domain.State.READY,
ready_at=timezone.make_aware(datetime.combine(date.today() + timedelta(days=1), datetime.min.time())),
first_ready_at=timezone.make_aware(datetime.combine(date.today() + timedelta(days=1), datetime.min.time())),
)
self.domain_information_1, _ = DomainInformation.objects.get_or_create(
@ -450,10 +450,10 @@ class ExportDataTest(TestCase):
def test_export_domains_to_writer_with_date_filter_pulls_domains_in_range(self):
"""Test that domains that are
1. READY and their ready_at dates are in range
1. READY and their first_ready_at dates are in range
2. DELETED and their deleted_at dates are in range
are pulled when the growth report conditions are applied to export_domains_to_writed.
Test that ready domains are sorted by ready_at/deleted_at dates first, names second.
Test that ready domains are sorted by first_ready_at/deleted_at dates first, names second.
We considered testing export_data_growth_to_csv which calls export_domains_to_writer
and would have been easy to set up, but expected_content would contain created_at dates
@ -492,8 +492,8 @@ class ExportDataTest(TestCase):
"domain__state__in": [
Domain.State.READY,
],
"domain__ready_at__lt": end_date,
"domain__ready_at__gt": start_date,
"domain__first_ready_at__lt": end_date,
"domain__first_ready_at__gt": start_date,
}
filter_conditions_for_additional_domains = {
"domain__state__in": [

View file

@ -41,7 +41,7 @@ def write_row(writer, columns, domain_info):
"Status": domain_info.domain.state,
"Expiration date": domain_info.domain.expiration_date,
"Created at": domain_info.domain.created_at,
"Ready at": domain_info.domain.ready_at,
"Ready at": domain_info.domain.first_ready_at,
"Deleted at": domain_info.domain.deleted_at,
}
writer.writerow([FIELDS.get(column, "") for column in columns])
@ -232,8 +232,8 @@ def export_data_growth_to_csv(csv_file, start_date, end_date):
]
filter_condition = {
"domain__state__in": [Domain.State.READY],
"domain__ready_at__lt": end_date_formatted,
"domain__ready_at__gt": start_date_formatted,
"domain__first_ready_at__lt": end_date_formatted,
"domain__first_ready_at__gt": start_date_formatted,
}
# We also want domains deleted between sar and end dates, sorted