mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Linter + test case
This commit is contained in:
parent
82c03907df
commit
e94f9dc51b
3 changed files with 16 additions and 8 deletions
|
@ -13,6 +13,7 @@ from . import models
|
|||
from auditlog.models import LogEntry # type: ignore
|
||||
from auditlog.admin import LogEntryAdmin # type: ignore
|
||||
from django_fsm import TransitionNotAllowed # type: ignore
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -729,10 +730,9 @@ class DomainAdmin(ListHeaderAdmin):
|
|||
except RegistryError as err:
|
||||
# Human-readable mappings of ErrorCodes. Can be expanded.
|
||||
error_messages = {
|
||||
ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION:
|
||||
f"Cannot delete Domain when in status {obj.status}",
|
||||
ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION:
|
||||
"This subdomain is being used as a hostname on another domain",
|
||||
# noqa on these items as black wants to reformat to an invalid length
|
||||
ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION: f"Cannot delete Domain when in status {obj.status}", # noqa
|
||||
ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION: "This subdomain is being used as a hostname on another domain", # noqa
|
||||
}
|
||||
|
||||
message = "Cannot connect to the registry"
|
||||
|
|
|
@ -6,6 +6,7 @@ import logging
|
|||
from django.apps import apps
|
||||
from django.db import models
|
||||
from django_fsm import FSMField, transition # type: ignore
|
||||
from registrar.models.domain import Domain
|
||||
|
||||
from .utility.time_stamped_model import TimeStampedModel
|
||||
from ..utility.email import send_templated_email, EmailSendingError
|
||||
|
@ -610,8 +611,10 @@ class DomainApplication(TimeStampedModel):
|
|||
|
||||
As side effects this will delete the domain and domain_information
|
||||
(will cascade), and send an email notification."""
|
||||
|
||||
if self.status == self.APPROVED:
|
||||
domain_state = self.approved_domain.state
|
||||
# Only reject if it exists on EPP
|
||||
if domain_state != Domain.State.UNKNOWN:
|
||||
self.approved_domain.deletedInEpp()
|
||||
self.approved_domain.delete()
|
||||
self.approved_domain = None
|
||||
|
@ -638,7 +641,10 @@ class DomainApplication(TimeStampedModel):
|
|||
and domain_information (will cascade) when they exist."""
|
||||
|
||||
if self.status == self.APPROVED:
|
||||
self.approved_domain.delete_request()
|
||||
domain_state = self.approved_domain.state
|
||||
# Only reject if it exists on EPP
|
||||
if domain_state != Domain.State.UNKNOWN:
|
||||
self.approved_domain.deletedInEpp()
|
||||
self.approved_domain.delete()
|
||||
self.approved_domain = None
|
||||
|
||||
|
|
|
@ -287,8 +287,9 @@ class TestDomainApplicationAdminForm(TestCase):
|
|||
)
|
||||
|
||||
|
||||
class TestDomainApplicationAdmin(TestCase):
|
||||
class TestDomainApplicationAdmin(MockEppLib):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.factory = RequestFactory()
|
||||
self.admin = DomainApplicationAdmin(
|
||||
|
@ -839,6 +840,7 @@ class TestDomainApplicationAdmin(TestCase):
|
|||
domain_information.refresh_from_db()
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
Domain.objects.all().delete()
|
||||
DomainInformation.objects.all().delete()
|
||||
DomainApplication.objects.all().delete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue