From 7ed916a86489c295b50e6f1cda06ac4e7bc7c6e1 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Tue, 17 Oct 2023 14:56:50 -0400 Subject: [PATCH] lint --- src/registrar/tests/common.py | 42 +++++++++++++++---------------- src/registrar/tests/test_views.py | 1 + 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index f73082ab4..a9f38db03 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -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") diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index ce901626b..0e8f895af 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1626,6 +1626,7 @@ class TestDomainSecurityEmail(TestDomainOverview): response = self.client.get(reverse("domain", kwargs={"pk": self.domain.id})) self.assertEqual(response.status_code, 403) + class TestDomainDNSSEC(TestDomainOverview): """MockEPPLib is already inherited."""