From 2bebf703941224d0ee9121ee0f0e969a532a7c99 Mon Sep 17 00:00:00 2001 From: lizpearl Date: Fri, 11 Apr 2025 10:35:46 -0500 Subject: [PATCH 1/3] Include the expiration date when testing for is_expiring --- src/registrar/models/domain.py | 4 ++++ src/registrar/tests/test_views.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 63483c18e..85a8a8cd9 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1284,7 +1284,11 @@ class Domain(TimeStampedModel, DomainHelper): now = timezone.now().date() threshold_date = now + timedelta(days=60) +<<<<<<< Updated upstream return now < self.expiration_date <= threshold_date +======= + return now <= self.expiration_date <= threshold_date +>>>>>>> Stashed changes def state_display(self, request=None): """Return the display status of the domain.""" diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 3f5413e5a..b24069357 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1,4 +1,4 @@ -from datetime import date +from datetime import date, timedelta from django.test import Client, TestCase, override_settings from django.contrib.auth import get_user_model from django_webtest import WebTest # type: ignore @@ -191,7 +191,7 @@ class HomeTests(TestWithUser): with self.subTest(domain_name=domain_name, state=state, expected_message=expected_message): # Create a domain and a UserRole with the given params test_domain, _ = Domain.objects.get_or_create(name=domain_name, state=state) - test_domain.expiration_date = date.today() + test_domain.expiration_date = date.today() + timedelta(days=61) test_domain.save() user_role, _ = UserDomainRole.objects.get_or_create( @@ -235,6 +235,31 @@ class HomeTests(TestWithUser): test_role.delete() test_domain.delete() + @less_console_noise_decorator + def test_state_help_text_is_expiring(self): + """Tests if each domain state has help text when expired""" + is_expiring_text = "This domain is expiring soon" + test_domain, _ = Domain.objects.get_or_create(name="is-expiring.gov", state=Domain.State.READY) + test_domain.expiration_date = date.today() + test_domain.save() + + test_role, _ = UserDomainRole.objects.get_or_create( + user=self.user, domain=test_domain, role=UserDomainRole.Roles.MANAGER + ) + + # Grab the json response of the domains list + response = self.client.get("/get-domains-json/") + + # Make sure the domain is in the response + self.assertContains(response, "is-expiring.gov", count=1) + + # Check that we have the right text content. + self.assertContains(response, is_expiring_text, count=1) + + test_role.delete() + test_domain.delete() + + @less_console_noise_decorator def test_state_help_text_no_expiration_date(self): """Tests if each domain state has help text when expiration date is None""" From d322c3f645bf2d423d228f208f6a9a5530efcdbe Mon Sep 17 00:00:00 2001 From: lizpearl Date: Fri, 11 Apr 2025 10:37:40 -0500 Subject: [PATCH 2/3] Commit now saved merge conflict --- src/registrar/models/domain.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 85a8a8cd9..7c9a43f57 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1284,11 +1284,7 @@ class Domain(TimeStampedModel, DomainHelper): now = timezone.now().date() threshold_date = now + timedelta(days=60) -<<<<<<< Updated upstream - return now < self.expiration_date <= threshold_date -======= return now <= self.expiration_date <= threshold_date ->>>>>>> Stashed changes def state_display(self, request=None): """Return the display status of the domain.""" From 4491e0aa2f525ef001b4dda44fe222e560342364 Mon Sep 17 00:00:00 2001 From: lizpearl Date: Fri, 11 Apr 2025 10:44:19 -0500 Subject: [PATCH 3/3] Removed extra line --- src/registrar/tests/test_views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index b24069357..01d5636b7 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -259,7 +259,6 @@ class HomeTests(TestWithUser): test_role.delete() test_domain.delete() - @less_console_noise_decorator def test_state_help_text_no_expiration_date(self): """Tests if each domain state has help text when expiration date is None"""