mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-01 02:03:56 +02:00
Linting
This commit is contained in:
parent
bb3e71380f
commit
6dd846f8b6
2 changed files with 14 additions and 39 deletions
|
@ -144,24 +144,15 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""Returns a help message for a desired state. If none is found, an empty string is returned"""
|
"""Returns a help message for a desired state. If none is found, an empty string is returned"""
|
||||||
help_texts = {
|
help_texts = {
|
||||||
# For now, unknown has the same message as DNS_NEEDED
|
# For now, unknown has the same message as DNS_NEEDED
|
||||||
cls.UNKNOWN:(
|
cls.UNKNOWN: ("Before this domain can be used, " "you’ll need to add name server addresses."),
|
||||||
"Before this domain can be used, "
|
cls.DNS_NEEDED: ("Before this domain can be used, " "you’ll need to add name server addresses."),
|
||||||
"you’ll need to add name server addresses."
|
|
||||||
),
|
|
||||||
cls.DNS_NEEDED: (
|
|
||||||
"Before this domain can be used, "
|
|
||||||
"you’ll need to add name server addresses."
|
|
||||||
),
|
|
||||||
cls.READY: "This domain has name servers and is ready for use.",
|
cls.READY: "This domain has name servers and is ready for use.",
|
||||||
cls.ON_HOLD: (
|
cls.ON_HOLD: (
|
||||||
"This domain is administratively paused, "
|
"This domain is administratively paused, "
|
||||||
"so it can’t be edited and won’t resolve in DNS. "
|
"so it can’t be edited and won’t resolve in DNS. "
|
||||||
"Contact help@get.gov for details."
|
"Contact help@get.gov for details."
|
||||||
),
|
),
|
||||||
cls.DELETED: (
|
cls.DELETED: ("This domain has been removed and " "is no longer registered to your organization."),
|
||||||
"This domain has been removed and "
|
|
||||||
"is no longer registered to your organization."
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return help_texts.get(state, "")
|
return help_texts.get(state, "")
|
||||||
|
@ -1433,8 +1424,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# Given expired is not a physical state, but it is displayed as such,
|
# Given expired is not a physical state, but it is displayed as such,
|
||||||
# We need custom logic to determine this message.
|
# We need custom logic to determine this message.
|
||||||
help_text = (
|
help_text = (
|
||||||
"This domain has expired, but it is still online. "
|
"This domain has expired, but it is still online. " "To renew this domain, contact help@get.gov."
|
||||||
"To renew this domain, contact help@get.gov."
|
|
||||||
)
|
)
|
||||||
return help_text
|
return help_text
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.test import Client, TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from .common import AuditedAdminMockData, MockEppLib, MockSESClient, completed_application, create_user, generic_domain_object # type: ignore
|
from .common import MockEppLib, MockSESClient, completed_application, create_user # type: ignore
|
||||||
from django_webtest import WebTest # type: ignore
|
from django_webtest import WebTest # type: ignore
|
||||||
import boto3_mocking # type: ignore
|
import boto3_mocking # type: ignore
|
||||||
|
|
||||||
|
@ -110,24 +110,15 @@ class LoggedInTests(TestWithUser):
|
||||||
"""Tests if each domain state has help text"""
|
"""Tests if each domain state has help text"""
|
||||||
|
|
||||||
# Get the expected text content of each state
|
# Get the expected text content of each state
|
||||||
deleted_text = (
|
deleted_text = "Before this domain can be used, " "you’ll need to add name server addresses."
|
||||||
"Before this domain can be used, "
|
dns_needed_text = "Before this domain can be used, " "you’ll need to add name server addresses."
|
||||||
"you’ll need to add name server addresses."
|
|
||||||
)
|
|
||||||
dns_needed_text = (
|
|
||||||
"Before this domain can be used, "
|
|
||||||
"you’ll need to add name server addresses."
|
|
||||||
)
|
|
||||||
ready_text = "This domain has name servers and is ready for use."
|
ready_text = "This domain has name servers and is ready for use."
|
||||||
on_hold_text = (
|
on_hold_text = (
|
||||||
"This domain is administratively paused, "
|
"This domain is administratively paused, "
|
||||||
"so it can’t be edited and won’t resolve in DNS. "
|
"so it can’t be edited and won’t resolve in DNS. "
|
||||||
"Contact help@get.gov for details."
|
"Contact help@get.gov for details."
|
||||||
)
|
)
|
||||||
deleted_text = (
|
deleted_text = "This domain has been removed and " "is no longer registered to your organization."
|
||||||
"This domain has been removed and "
|
|
||||||
"is no longer registered to your organization."
|
|
||||||
)
|
|
||||||
# Generate a mapping of domain names, the state, and expected messages for the subtest
|
# Generate a mapping of domain names, the state, and expected messages for the subtest
|
||||||
test_cases = [
|
test_cases = [
|
||||||
("deleted.gov", Domain.State.DELETED, deleted_text),
|
("deleted.gov", Domain.State.DELETED, deleted_text),
|
||||||
|
@ -138,7 +129,6 @@ class LoggedInTests(TestWithUser):
|
||||||
]
|
]
|
||||||
for domain_name, state, expected_message in test_cases:
|
for domain_name, state, expected_message in test_cases:
|
||||||
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()
|
||||||
|
@ -164,17 +154,12 @@ class LoggedInTests(TestWithUser):
|
||||||
|
|
||||||
def test_state_help_text_expired(self):
|
def test_state_help_text_expired(self):
|
||||||
"""Tests if each domain state has help text when expired"""
|
"""Tests if each domain state has help text when expired"""
|
||||||
expired_text = (
|
expired_text = "This domain has expired, but it is still online. " "To renew this domain, contact help@get.gov."
|
||||||
"This domain has expired, but it is still online. "
|
|
||||||
"To renew this domain, contact help@get.gov."
|
|
||||||
)
|
|
||||||
test_domain, _ = Domain.objects.get_or_create(name="expired.gov", state=Domain.State.READY)
|
test_domain, _ = Domain.objects.get_or_create(name="expired.gov", state=Domain.State.READY)
|
||||||
test_domain.expiration_date = date(2011, 10, 10)
|
test_domain.expiration_date = date(2011, 10, 10)
|
||||||
test_domain.save()
|
test_domain.save()
|
||||||
|
|
||||||
UserDomainRole.objects.get_or_create(
|
UserDomainRole.objects.get_or_create(user=self.user, domain=test_domain, role=UserDomainRole.Roles.MANAGER)
|
||||||
user=self.user, domain=test_domain, role=UserDomainRole.Roles.MANAGER
|
|
||||||
)
|
|
||||||
|
|
||||||
# Grab the home page
|
# Grab the home page
|
||||||
response = self.client.get("/")
|
response = self.client.get("/")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue