mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
fixed linting and merge bug
This commit is contained in:
parent
e4c7155aca
commit
4292c38b47
5 changed files with 27 additions and 24 deletions
|
@ -4,7 +4,6 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from registrar.models.public_contact import PublicContact
|
||||
from registrar.models.utility.admin_sort_fields import AdminSortFields
|
||||
from . import models
|
||||
from auditlog.models import LogEntry # type: ignore
|
||||
|
@ -220,7 +219,7 @@ class DomainAdmin(ListHeaderAdmin):
|
|||
"_remove_client_hold": self.do_remove_client_hold,
|
||||
"_edit_domain": self.do_edit_domain,
|
||||
"_delete_domain": self.do_delete_domain,
|
||||
"_get_status": self.do_get_status
|
||||
"_get_status": self.do_get_status,
|
||||
}
|
||||
|
||||
# Check which action button was pressed and call the corresponding function
|
||||
|
|
|
@ -116,14 +116,11 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
READY = "ready"
|
||||
|
||||
# Registrar manually changed state to client hold
|
||||
ON_HOLD = "client hold"
|
||||
ON_HOLD = "on hold"
|
||||
|
||||
# previously existed but has been deleted from the registry
|
||||
DELETED = "deleted"
|
||||
|
||||
# when a domain is on hold
|
||||
ONHOLD = "onhold"
|
||||
|
||||
class Cache(property):
|
||||
"""
|
||||
Python descriptor to turn class methods into properties.
|
||||
|
@ -453,10 +450,13 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
try:
|
||||
contacts = self._get_property("contacts")
|
||||
for contact in contacts:
|
||||
##zander don't do this just to do the bare bones here
|
||||
if "type" in contact.keys() and contact["type"] == PublicContact.ContactTypeChoices.SECURITY:
|
||||
tempContact= self.get_default_security_contact()
|
||||
tempContact.email=contact["email"]
|
||||
# zander don't do this just to do the bare bones here
|
||||
if (
|
||||
"type" in contact.keys()
|
||||
and contact["type"] == PublicContact.ContactTypeChoices.SECURITY
|
||||
):
|
||||
tempContact = self.get_default_security_contact()
|
||||
tempContact.email = contact["email"]
|
||||
return tempContact
|
||||
|
||||
except Exception as err: # use better error handling
|
||||
|
@ -642,14 +642,12 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
def clientHoldStatus(self):
|
||||
return epp.Status(state=self.Status.CLIENT_HOLD, description="", lang="en")
|
||||
|
||||
@transition(field="state", source=[State.READY], target=State.ONHOLD)
|
||||
def _place_client_hold(self):
|
||||
"""This domain should not be active.
|
||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||
request = commands.UpdateDomain(name=self.name, add=[self.clientHoldStatus()])
|
||||
registry.send(request)
|
||||
|
||||
@transition(field="state", source=[State.ONHOLD], target=State.READY)
|
||||
def _remove_client_hold(self):
|
||||
"""This domain is okay to be active.
|
||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||
|
@ -793,7 +791,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
administrative_contact.save()
|
||||
|
||||
@transition(field="state", source=State.DNS_NEEDED, target=State.ON_HOLD)
|
||||
def clientHold(self):
|
||||
def place_client_hold(self):
|
||||
"""place a clienthold on a domain (no longer should resolve)"""
|
||||
# TODO - ensure all requirements for client hold are made here
|
||||
# (check prohibited statuses)
|
||||
|
|
|
@ -154,9 +154,16 @@ class TestDomainCache(MockEppLib):
|
|||
self.assertEquals(domain._cache, {})
|
||||
|
||||
# send should have been called only once
|
||||
self.mockedSendFunction.assert_has_calls([call(commands.InfoDomain(name='igorville.gov', auth_info=None), cleaned=True),
|
||||
call(commands.InfoContact(id='123', auth_info=None), cleaned=True),
|
||||
call(commands.InfoHost(name='fake.host.com'), cleaned=True)])
|
||||
self.mockedSendFunction.assert_has_calls(
|
||||
[
|
||||
call(
|
||||
commands.InfoDomain(name="igorville.gov", auth_info=None),
|
||||
cleaned=True,
|
||||
),
|
||||
call(commands.InfoContact(id="123", auth_info=None), cleaned=True),
|
||||
call(commands.InfoHost(name="fake.host.com"), cleaned=True),
|
||||
]
|
||||
)
|
||||
|
||||
def test_cache_used_when_avail(self):
|
||||
"""Cache is pulled from if the object has already been accessed"""
|
||||
|
@ -259,9 +266,8 @@ class TestDomainCreation(TestCase):
|
|||
|
||||
def test_empty_domain_creation(self):
|
||||
"""Can't create a completely empty domain."""
|
||||
#psycopg2.errors.NotNullViolation is being thrown
|
||||
#which causes integrity error
|
||||
with self.assertRaisesRegex(IntegrityError,):
|
||||
|
||||
with self.assertRaises(IntegrityError):
|
||||
Domain.objects.create()
|
||||
|
||||
def test_minimal_creation(self):
|
||||
|
@ -271,7 +277,7 @@ class TestDomainCreation(TestCase):
|
|||
def test_duplicate_creation(self):
|
||||
"""Can't create domain if name is not unique."""
|
||||
Domain.objects.create(name="igorville.gov")
|
||||
with self.assertRaisesRegex(IntegrityError):
|
||||
with self.assertRaises(IntegrityError):
|
||||
Domain.objects.create(name="igorville.gov")
|
||||
|
||||
@skip("cannot activate a domain without mock registry")
|
||||
|
|
|
@ -1132,7 +1132,7 @@ class TestDomainDetail(TestWithDomainPermissions, WebTest):
|
|||
self.app.set_user(self.user.username)
|
||||
self.client.force_login(self.user)
|
||||
|
||||
##here
|
||||
##here
|
||||
def test_domain_detail_link_works(self):
|
||||
home_page = self.app.get("/")
|
||||
self.assertContains(home_page, "igorville.gov")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue