fixed linting and merge bug

This commit is contained in:
Alysia Broddrick 2023-09-12 18:06:06 -07:00
parent e4c7155aca
commit 4292c38b47
No known key found for this signature in database
GPG key ID: 03917052CD0F06B7
5 changed files with 27 additions and 24 deletions

View file

@ -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
@ -243,7 +242,7 @@ class DomainAdmin(ListHeaderAdmin):
("Domain %s Should now be deleted " ". Thanks!") % obj.name,
)
return HttpResponseRedirect(".")
def do_get_status(self, request, obj):
try:
statuses = obj.statuses

View file

@ -17,4 +17,4 @@ class Command(BaseCommand):
UserFixture.load()
DomainApplicationFixture.load()
DomainFixture.load()
logger.info("All fixtures loaded.")
logger.info("All fixtures loaded.")

View file

@ -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)
@ -1012,7 +1010,7 @@ class Domain(TimeStampedModel, DomainHelper):
"up_date": getattr(data, "up_date", ...),
"voice": getattr(data, "voice", ...),
}
cleaned["contacts"].append(
{k: v for k, v in contact.items() if v is not ...}
)

View file

@ -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")

View file

@ -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")