This commit is contained in:
Rachid Mrad 2023-10-17 14:56:50 -04:00
parent fa373993bf
commit 7ed916a864
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF
2 changed files with 21 additions and 22 deletions

View file

@ -795,28 +795,8 @@ class MockEppLib(TestCase):
return self.mockInfoContactCommands(_request, cleaned)
elif isinstance(_request, commands.UpdateDomain):
return self.mockUpdateDomainCommands(_request, cleaned)
elif (
isinstance(_request, commands.CreateContact)
and getattr(_request, "id", None) == "fail"
and self.mockedSendFunction.call_count == 3
):
# use this for when a contact is being updated
# sets the second send() to fail
raise RegistryError(code=ErrorCode.OBJECT_EXISTS)
elif (
isinstance(_request, commands.CreateContact)
and getattr(_request, "email", None) == "test@failCreate.gov"
):
# use this for when a contact is being updated
# mocks a registry error on creation
raise RegistryError(code=None)
elif (
isinstance(_request, commands.CreateContact)
and getattr(_request, "email", None) == "test@contactError.gov"
):
# use this for when a contact is being updated
# mocks a registry error on creation
raise ContactError(code=ContactErrorCodes.CONTACT_TYPE_NONE)
elif isinstance(_request, commands.CreateContact):
return self.mockCreateContactCommands(_request, cleaned)
elif isinstance(_request, commands.CreateHost):
return MagicMock(
res_data=[self.mockDataHostChange],
@ -913,6 +893,24 @@ class MockEppLib(TestCase):
return MagicMock(res_data=[mocked_result])
def mockCreateContactCommands(self, _request, cleaned):
if (
getattr(_request, "id", None) == "fail"
and self.mockedSendFunction.call_count == 3
):
# use this for when a contact is being updated
# sets the second send() to fail
raise RegistryError(code=ErrorCode.OBJECT_EXISTS)
elif getattr(_request, "email", None) == "test@failCreate.gov":
# use this for when a contact is being updated
# mocks a registry error on creation
raise RegistryError(code=None)
elif getattr(_request, "email", None) == "test@contactError.gov":
# use this for when a contact is being updated
# mocks a contact error on creation
raise ContactError(code=ContactErrorCodes.CONTACT_TYPE_NONE)
return MagicMock(res_data=[self.mockDataInfoHosts])
def setUp(self):
"""mock epp send function as this will fail locally"""
self.mockSendPatch = patch("registrar.models.domain.registry.send")