linter fixes

This commit is contained in:
matthewswspence 2024-12-04 13:37:23 -06:00
parent 74eeae19e8
commit 89253a1626
No known key found for this signature in database
GPG key ID: FB458202A7852BA4
3 changed files with 22 additions and 26 deletions

View file

@ -747,11 +747,7 @@ class Domain(TimeStampedModel, DomainHelper):
successTotalNameservers = len(oldNameservers) - deleteCount + addToDomainCount
try:
self._delete_hosts_if_not_used(hostsToDelete=deleted_values)
except:
# in this case we don't care if there's an error, and it will be logged in the function.
pass
self._delete_hosts_if_not_used(hostsToDelete=deleted_values)
if successTotalNameservers < 2:
try:
@ -1034,10 +1030,10 @@ class Domain(TimeStampedModel, DomainHelper):
# if registry error occurs, log the error, and raise it as well
logger.error(f"registry error removing client hold: {err}")
raise (err)
def _delete_nonregistrant_contacts(self):
"""Non-registrant contacts associated with this domain will be deleted.
RegistryErrors will be logged and raised. Error
RegistryErrors will be logged and raised. Error
handling should be provided by the caller.
"""
logger.info("Deleting contacts for %s", self.name)
@ -1048,8 +1044,7 @@ class Domain(TimeStampedModel, DomainHelper):
# registrants have to be deleted after the domain
if contact != PublicContact.ContactTypeChoices.REGISTRANT:
self._delete_contact(contact, id)
def _delete_subdomains(self):
"""Subdomains of this domain should be deleted from the registry.
Subdomains which are used by other domains (eg as a hostname) will
@ -1690,10 +1685,10 @@ class Domain(TimeStampedModel, DomainHelper):
)
raise e
def _delete_contact(self, contact_name: str, registry_id: str):
"""Try to delete a contact from the registry.
raises:
RegistryError: if the registry is unable to delete the contact
"""
@ -1703,10 +1698,8 @@ class Domain(TimeStampedModel, DomainHelper):
return registry.send(req, cleaned=True).res_data[0]
except RegistryError as error:
logger.error(
"Registry threw error when trying to delete contact id %s contact type is %s, error code is\n %s full error is %s", # noqa
contact.registry_id,
contact.contact_type,
error.code,
"Registry threw error when trying to delete contact %s, error: %s", # noqa
contact_name,
error,
)
raise error
@ -1834,7 +1827,7 @@ class Domain(TimeStampedModel, DomainHelper):
logger.info("Did not remove host %s because it is in use on another domain." % nameserver)
else:
logger.error("Error _delete_hosts_if_not_used, code was %s error was %s" % (e.code, e))
raise e
def _fix_unknown_state(self, cleaned):

View file

@ -1672,7 +1672,7 @@ class MockEppLib(TestCase):
res_data=[self.mockDataHostChange],
code=ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY,
)
def mockDeleteHostCommands(self, _request, cleaned):
host = getattr(_request, "name", None)
if "sharedhost.com" in host:
@ -1814,15 +1814,15 @@ class MockEppLib(TestCase):
# mocks a contact error on creation
raise ContactError(code=ContactErrorCodes.CONTACT_TYPE_NONE)
return MagicMock(res_data=[self.mockDataInfoHosts])
def mockDeleteContactCommands(self, _request, cleaned):
if getattr(_request, "id", None) == "fail":
raise RegistryError(code=ErrorCode.OBJECT_EXISTS)
else:
return MagicMock(
res_data=[self.mockDataInfoContact],
code=ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY,
)
res_data=[self.mockDataInfoContact],
code=ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY,
)
def setUp(self):
"""mock epp send function as this will fail locally"""

View file

@ -2643,7 +2643,7 @@ class TestAnalystDelete(MockEppLib):
self.mockedSendFunction.assert_has_calls(
[
call(
commands.DeleteHost(name='ns1.sharedhost.com'),
commands.DeleteHost(name="ns1.sharedhost.com"),
cleaned=True,
),
]
@ -2664,7 +2664,7 @@ class TestAnalystDelete(MockEppLib):
And `state` is set to `DELETED`
"""
# with less_console_noise():
# Desired domain
# Desired domain
domain, _ = Domain.objects.get_or_create(name="freeman.gov", state=Domain.State.ON_HOLD)
# Put the domain in client hold
domain.place_client_hold()
@ -2675,12 +2675,15 @@ class TestAnalystDelete(MockEppLib):
# Check that the host and contacts are deleted, order doesn't matter
self.mockedSendFunction.assert_has_calls(
[
call(commands.DeleteHost(name='fake.host.com'), cleaned=True),
call(commands.DeleteHost(name="fake.host.com"), cleaned=True),
call(commands.DeleteContact(id="securityContact"), cleaned=True),
call(commands.DeleteContact(id="technicalContact"), cleaned=True),
call(commands.DeleteContact(id="adminContact"),cleaned=True,)
call(
commands.DeleteContact(id="adminContact"),
cleaned=True,
),
],
any_order=True
any_order=True,
)
# These calls need to be in order