diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 293e72cd8..c76cc717f 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -21,7 +21,6 @@ from .utility.time_stamped_model import TimeStampedModel from .public_contact import PublicContact - logger = logging.getLogger(__name__) @@ -539,7 +538,6 @@ class Domain(TimeStampedModel, DomainHelper): current_contact = PublicContact.objects.filter( registry_id=contact.registry_id ).get() - logger.debug(f"current contact was accessed {current_contact}") if current_contact.email != contact.email: self._update_epp_contact(contact=contact) @@ -751,7 +749,7 @@ class Domain(TimeStampedModel, DomainHelper): def generic_contact_getter( self, contact_type_choice: PublicContact.ContactTypeChoices - ) -> PublicContact: + ) -> PublicContact | None: """Abstracts the cache logic on EppLib contact items contact_type_choice is a literal in PublicContact.ContactTypeChoices, @@ -773,8 +771,9 @@ class Domain(TimeStampedModel, DomainHelper): try: contacts = self._get_property(desired_property) except KeyError as error: + # Q: Should we be raising an error instead? logger.error(f"Could not find {contact_type_choice}: {error}") - raise error + return None else: # Grab from cache cached_contact = self.grab_contact_in_keys(contacts, contact_type_choice) @@ -841,7 +840,7 @@ class Domain(TimeStampedModel, DomainHelper): # If the for loop didn't do a return, # then we know that it doesn't exist within cache logger.info( - f"Requested contact {contact.registry_id} " "Does not exist in cache." + f"Requested contact {contact.registry_id} does not exist in cache." ) return None @@ -890,7 +889,6 @@ class Domain(TimeStampedModel, DomainHelper): while not exitEarly and count < 3: try: logger.info("Getting domain info from epp") - logger.debug(f"domain info name is... {self.__dict__}") req = commands.InfoDomain(name=self.name) domainInfo = registry.send(req, cleaned=True).res_data[0] exitEarly = True @@ -1242,7 +1240,7 @@ class Domain(TimeStampedModel, DomainHelper): # Saves to DB if it doesn't exist already. # Doesn't run custom save logic, just saves to DB public_contact.save(skip_epp_save=True) - logger.debug(f"Created a new PublicContact: {public_contact}") + logger.info(f"Created a new PublicContact: {public_contact}") # Append the item we just created return public_contact @@ -1265,7 +1263,6 @@ class Domain(TimeStampedModel, DomainHelper): def _invalidate_cache(self): """Remove cache data when updates are made.""" - logger.debug(f"cache was cleared! {self.__dict__}") self._cache = {} def _get_property(self, property): @@ -1277,7 +1274,6 @@ class Domain(TimeStampedModel, DomainHelper): ) if property in self._cache: - logger.debug(self._cache[property]) return self._cache[property] else: raise KeyError( diff --git a/src/registrar/tests/test_models_domain.py b/src/registrar/tests/test_models_domain.py index 9a0f52e6a..f82441231 100644 --- a/src/registrar/tests/test_models_domain.py +++ b/src/registrar/tests/test_models_domain.py @@ -48,6 +48,7 @@ class TestDomainCache(MockEppLib): # using a setter should clear the cache domain.expiration_date = datetime.date.today() + self.assertEquals(domain._cache, {}) # send should have been called only once self.mockedSendFunction.assert_has_calls( @@ -97,7 +98,7 @@ class TestDomainCache(MockEppLib): expectedContactsList = [domain.security_contact] expectedHostsDict = { "name": self.mockDataInfoDomain.hosts[0], - "cr_date": self.mockDataInfoDomain.cr_date, + "cr_date": self.mockDataInfoHosts.cr_date, } # this can be changed when the getter for contacts is implemented @@ -112,7 +113,6 @@ class TestDomainCache(MockEppLib): # The contact list should not contain what is sent by the registry by default, # as _fetch_cache will transform the type to PublicContact self.assertNotEqual(domain._cache["contacts"], expectedUnfurledContactsList) - self.assertEqual(domain._cache["contacts"], expectedContactsList) # get and check hosts is set correctly @@ -575,18 +575,6 @@ class TestRegistrantContacts(MockEppLib): """ raise - @skip("not implemented yet") - def test_contact_getters_cache(self): - """ - Scenario: A user is grabbing a domain that has multiple contact objects - When each contact is retrieved from cache - Then the user retrieves the correct contact objects - """ - - @skip("not implemented yet") - def test_epp_public_contact_mapper(self): - pass - def test_contact_getter_security(self): self.maxDiff = None # Create prexisting object...