fixed minor bug and formatting

This commit is contained in:
David Kennedy 2023-12-21 13:55:23 -05:00
parent bd3c150067
commit ed7868efba
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 12 additions and 11 deletions

View file

@ -298,12 +298,12 @@ class Domain(TimeStampedModel, DomainHelper):
try:
# attempt to retrieve hosts from registry and store in cache and db
hosts = self._get_property("hosts")
except Exception as err:
except Exception:
# If exception raised returning hosts from registry, get from db
hosts = []
for host in self.host.all():
host_name = host.name
ips = [ip.address for ip in host.ip.all()]
for hostobj in self.host.all():
host_name = hostobj.name
ips = [ip.address for ip in hostobj.ip.all()]
hosts.append({"name": host_name, "addrs": ips})
# TODO-687 fix this return value

View file

@ -1526,7 +1526,7 @@ class TestRegistrantNameservers(MockEppLib):
host, _ = Host.objects.get_or_create(domain=domain, name="ns1.fake.gov")
host_ip, _ = HostIP.objects.get_or_create(host=host, address="1.1.1.1")
# mock that registry throws an error on
# mock that registry throws an error on the InfoHost send
def side_effect(_request, cleaned):
raise RegistryError(code=ErrorCode.COMMAND_FAILED)
@ -1554,8 +1554,9 @@ class TestRegistrantNameservers(MockEppLib):
domain, _ = Domain.objects.get_or_create(name="fake.gov", state=Domain.State.READY)
# mock the get_or_create methods for Host and HostIP
with patch.object(Host.objects, 'get_or_create') as mock_host_get_or_create, \
patch.object(HostIP.objects, 'get_or_create') as mock_host_ip_get_or_create:
with patch.object(Host.objects, "get_or_create") as mock_host_get_or_create, patch.object(
HostIP.objects, "get_or_create"
) as mock_host_ip_get_or_create:
# Set the return value for the mocks
mock_host_get_or_create.return_value = (Host(), True)
mock_host_ip_get_or_create.return_value = (HostIP(), True)
@ -1563,10 +1564,10 @@ class TestRegistrantNameservers(MockEppLib):
# force fetch_cache to be called, which will return above documented mocked hosts
domain.nameservers
# assert that the mocks are called
mock_host_get_or_create.assert_called_once_with(domain=domain, name='fake.host.com')
mock_host_get_or_create.assert_called_once_with(domain=domain, name="fake.host.com")
# Retrieve the mocked_host from the return value of the mock
actual_mocked_host, _ = mock_host_get_or_create.return_value
mock_host_ip_get_or_create.assert_called_with(address='2.3.4.5', host=actual_mocked_host)
mock_host_ip_get_or_create.assert_called_with(address="2.3.4.5", host=actual_mocked_host)
self.assertEqual(mock_host_ip_get_or_create.call_count, 2)
@skip("not implemented yet")