mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Merge pull request #3728 from cisagov/el/add-is-expiring-edge-case
Include the expiration date when testing for is_expiring [EL]
This commit is contained in:
commit
3db39fb0f0
2 changed files with 27 additions and 3 deletions
|
@ -1284,7 +1284,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
now = timezone.now().date()
|
now = timezone.now().date()
|
||||||
|
|
||||||
threshold_date = now + timedelta(days=60)
|
threshold_date = now + timedelta(days=60)
|
||||||
return now < self.expiration_date <= threshold_date
|
return now <= self.expiration_date <= threshold_date
|
||||||
|
|
||||||
def state_display(self, request=None):
|
def state_display(self, request=None):
|
||||||
"""Return the display status of the domain."""
|
"""Return the display status of the domain."""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from datetime import date
|
from datetime import date, timedelta
|
||||||
from django.test import Client, TestCase, override_settings
|
from django.test import Client, TestCase, override_settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django_webtest import WebTest # type: ignore
|
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):
|
with self.subTest(domain_name=domain_name, state=state, expected_message=expected_message):
|
||||||
# Create a domain and a UserRole with the given params
|
# Create a domain and a UserRole with the given params
|
||||||
test_domain, _ = Domain.objects.get_or_create(name=domain_name, state=state)
|
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()
|
test_domain.save()
|
||||||
|
|
||||||
user_role, _ = UserDomainRole.objects.get_or_create(
|
user_role, _ = UserDomainRole.objects.get_or_create(
|
||||||
|
@ -235,6 +235,30 @@ class HomeTests(TestWithUser):
|
||||||
test_role.delete()
|
test_role.delete()
|
||||||
test_domain.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
|
@less_console_noise_decorator
|
||||||
def test_state_help_text_no_expiration_date(self):
|
def test_state_help_text_no_expiration_date(self):
|
||||||
"""Tests if each domain state has help text when expiration date is None"""
|
"""Tests if each domain state has help text when expiration date is None"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue