Remove print statements

This commit is contained in:
Rebecca Hsieh 2024-04-15 15:26:05 -07:00
parent cdf053547d
commit 3660932795
No known key found for this signature in database
2 changed files with 12 additions and 37 deletions

View file

@ -1686,48 +1686,41 @@ class Domain(TimeStampedModel, DomainHelper):
logger.error("Error _delete_hosts_if_not_used, code was %s error was %s" % (e.code, e)) logger.error("Error _delete_hosts_if_not_used, code was %s error was %s" % (e.code, e))
def _fix_unknown_state(self, cleaned): def _fix_unknown_state(self, cleaned):
# print("!! GOT INTO _fix_unknown_state")
try: try:
self._add_missing_contacts(cleaned) self._add_missing_contacts_if_unknown(cleaned)
except Exception as e: except Exception as e:
logger.error( logger.error(
"%s couldn't _add_missing_contacts, error was %s." "%s couldn't _add_missing_contacts_if_unknown, error was %s."
"Domain will still be in UNKNOWN state." % (self.name, e) "Domain will still be in UNKNOWN state." % (self.name, e)
) )
if len(self.nameservers) >= 2: if len(self.nameservers) >= 2:
# print("!! GOT INTO _fix_unknown_state -> have 2 or more nameserver so ready state")
self.ready() self.ready()
self.save() self.save()
@transition(field="state", source=State.UNKNOWN, target=State.DNS_NEEDED) @transition(field="state", source=State.UNKNOWN, target=State.DNS_NEEDED)
def _add_missing_contacts(self, cleaned): def _add_missing_contacts_if_unknown(self, cleaned):
""" """
_add_missing_contacts: Add contacts (SECURITY, TECHNICAL, and/or ADMINISTRATIVE) _add_missing_contacts_if_unknown: Add contacts (SECURITY, TECHNICAL, and/or ADMINISTRATIVE)
if they are missing, AND switch the state to DNS_NEEDED from UNKNOWN (if it if they are missing, AND switch the state to DNS_NEEDED from UNKNOWN (if it
is in an UNKNOWN state, that is an error state) is in an UNKNOWN state, that is an error state)
Note: The transition state change happens at the end of the function Note: The transition state change happens at the end of the function
""" """
# print("!! GOT INTO _add_missing_contacts ")
missingAdmin = True missingAdmin = True
missingSecurity = True missingSecurity = True
missingTech = True missingTech = True
# print("cleaned ", cleaned)
if len(cleaned.get("_contacts")) < 3: if len(cleaned.get("_contacts")) < 3:
# print("!! GOT INTO _add_missing_contacts -> in if statement")
for contact in cleaned.get("_contacts"): for contact in cleaned.get("_contacts"):
# this means we see it if contact.type == PublicContact.ContactTypeChoices.ADMINISTRATIVE:
if contact.type == "admin": mitestssingAdmin = False
missingAdmin = False if contact.type == PublicContact.ContactTypeChoices.SECURITY:
if contact.type == "security":
missingSecurity = False missingSecurity = False
if contact.type == "tech": if contact.type == PublicContact.ContactTypeChoices.TECHNICAL:
missingTech = False missingTech = False
# we are only creating if it doesn't exist so we don't overwrite # We are only creating if it doesn't exist so we don't overwrite
if missingAdmin: if missingAdmin:
administrative_contact = self.get_default_administrative_contact() administrative_contact = self.get_default_administrative_contact()
administrative_contact.save() administrative_contact.save()
@ -1738,8 +1731,6 @@ class Domain(TimeStampedModel, DomainHelper):
technical_contact = self.get_default_technical_contact() technical_contact = self.get_default_technical_contact()
technical_contact.save() technical_contact.save()
# print("!! GOT INTO _add_missing_contacts -> if statement finished ")
def _fetch_cache(self, fetch_hosts=False, fetch_contacts=False): def _fetch_cache(self, fetch_hosts=False, fetch_contacts=False):
"""Contact registry for info about a domain.""" """Contact registry for info about a domain."""
try: try:
@ -1749,7 +1740,6 @@ class Domain(TimeStampedModel, DomainHelper):
self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts) self._update_hosts_and_contacts(cleaned, fetch_hosts, fetch_contacts)
if self.state == self.State.UNKNOWN: if self.state == self.State.UNKNOWN:
# print("!! GOT INTO if self.state == self.State.UNKNOWN: ")
self._fix_unknown_state(cleaned) self._fix_unknown_state(cleaned)
if fetch_hosts: if fetch_hosts:
self._update_hosts_and_ips_in_db(cleaned) self._update_hosts_and_ips_in_db(cleaned)
@ -1951,7 +1941,6 @@ class Domain(TimeStampedModel, DomainHelper):
# Does the item we're grabbing match # Does the item we're grabbing match
# what we have in our DB? # what we have in our DB?
if existing_contact.email != public_contact.email or existing_contact.registry_id != public_contact.registry_id: if existing_contact.email != public_contact.email or existing_contact.registry_id != public_contact.registry_id:
print("******* IN IF STATEMENT!!!!! ***********")
existing_contact.delete() existing_contact.delete()
public_contact.save() public_contact.save()
logger.warning("Requested PublicContact is out of sync " "with DB.") logger.warning("Requested PublicContact is out of sync " "with DB.")

View file

@ -129,8 +129,6 @@ class TestDomainCache(MockEppLib):
# The contact list should not contain what is sent by the registry by default, # The contact list should not contain what is sent by the registry by default,
# as _fetch_cache will transform the type to PublicContact # as _fetch_cache will transform the type to PublicContact
self.assertNotEqual(domain._cache["contacts"], expectedUnfurledContactsList) self.assertNotEqual(domain._cache["contacts"], expectedUnfurledContactsList)
# print("!!! domain._cache[contacts] is", domain._cache["contacts"])
# print("!!! expectedContactsDict is", expectedContactsDict)
self.assertEqual(domain._cache["contacts"], expectedContactsDict) self.assertEqual(domain._cache["contacts"], expectedContactsDict)
@ -213,16 +211,12 @@ class TestDomainCache(MockEppLib):
self.mockDataSecurityContact.id, self.mockDataSecurityContact.id,
security, security,
) )
# print("self.mockDataInfoContact.id is", self.mockDataInfoContact.id)
print("self.mockDataSecurityContact", self.mockDataSecurityContact)
print("self.mockDataSecurityContact.id is", self.mockDataSecurityContact.id)
print("mapped is", mapped)
# id and registry_id are the same thing # id, registry_id, and contact are the same thing
expected_contact = PublicContact( expected_contact = PublicContact(
domain=domain, domain=domain,
contact_type=security, contact_type=security,
registry_id="securityContact", # self.mockDataInfoContact.id registry_id="securityContact",
email="security@mail.gov", email="security@mail.gov",
voice="+1.8882820870", voice="+1.8882820870",
fax="+1-212-9876543", fax="+1-212-9876543",
@ -240,8 +234,6 @@ class TestDomainCache(MockEppLib):
# two duplicate objects. We would expect # two duplicate objects. We would expect
# these not to have the same state. # these not to have the same state.
expected_contact._state = mapped._state expected_contact._state = mapped._state
print("!!! expected_contact._state is", expected_contact.__dict__)
print("!!! mapped.__dict__ is", mapped.__dict__)
# Mapped object is what we expect # Mapped object is what we expect
self.assertEqual(mapped.__dict__, expected_contact.__dict__) self.assertEqual(mapped.__dict__, expected_contact.__dict__)
@ -253,13 +245,6 @@ class TestDomainCache(MockEppLib):
contact_type=security, contact_type=security,
).get() ).get()
"""
!!! db_object is Registry Customer Service <123@mail.gov>id: 123 type: security
!!! in_db is Registry Customer Service <123@mail.gov>id: securityContact type: security
"""
print("!!! domain.security_contact.registry_id ", domain.security_contact.registry_id)
print("!!! db_object is", db_object)
print("!!! in_db is", in_db)
# DB Object is the same as the mapped object # DB Object is the same as the mapped object
self.assertEqual(db_object, in_db) self.assertEqual(db_object, in_db)
domain.security_contact = in_db domain.security_contact = in_db
@ -337,6 +322,7 @@ class TestDomainCache(MockEppLib):
""" """
with less_console_noise(): with less_console_noise():
domain, _ = Domain.objects.get_or_create(name="justnameserver.com") domain, _ = Domain.objects.get_or_create(name="justnameserver.com")
# trigger the getter
_ = domain.nameservers _ = domain.nameservers
self.assertEqual(domain.state, Domain.State.READY) self.assertEqual(domain.state, Domain.State.READY)
self.assertEqual(PublicContact.objects.filter(domain=domain.id).count(), 0) self.assertEqual(PublicContact.objects.filter(domain=domain.id).count(), 0)