mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Fix all but 1 unit test
This commit is contained in:
parent
757eba1d6e
commit
9f0ea37733
2 changed files with 29 additions and 12 deletions
|
@ -1059,8 +1059,12 @@ class MockEppLib(TestCase):
|
|||
ex_date=date(2023, 11, 15),
|
||||
)
|
||||
mockDataInfoContact = mockDataInfoDomain.dummyInfoContactResultData(
|
||||
"123", "123@mail.gov", datetime(2023, 5, 25, 19, 45, 35), "lastPw"
|
||||
id="SECURITY", email="security@mail.gov", cr_date=datetime(2023, 5, 25, 19, 45, 35), pw="lastPw"
|
||||
)
|
||||
mockDataSecurityContact = mockDataInfoDomain.dummyInfoContactResultData(
|
||||
id="SECURITY", email="security@mail.gov", cr_date=datetime(2023, 5, 25, 19, 45, 35), pw="lastPw"
|
||||
)
|
||||
print("!! mockDataInfoContact is", mockDataInfoContact)
|
||||
InfoDomainWithContacts = fakedEppObject(
|
||||
"fakepw",
|
||||
cr_date=make_aware(datetime(2023, 5, 25, 19, 45, 35)),
|
||||
|
@ -1497,6 +1501,7 @@ class MockEppLib(TestCase):
|
|||
"fakemeow.gov": (self.mockDataInfoDomainNotSubdomainNoIP, None),
|
||||
"subdomainwoip.gov": (self.mockDataInfoDomainSubdomainNoIP, None),
|
||||
"ddomain3.gov": (self.InfoDomainWithContacts, None),
|
||||
"igorville.gov": (self.InfoDomainWithContacts, None),
|
||||
}
|
||||
|
||||
# Retrieve the corresponding values from the dictionary
|
||||
|
@ -1510,8 +1515,6 @@ class MockEppLib(TestCase):
|
|||
def mockInfoContactCommands(self, _request, cleaned):
|
||||
mocked_result: info.InfoContactResultData
|
||||
|
||||
print("!!! _request is ", _request)
|
||||
|
||||
# For testing contact types
|
||||
match getattr(_request, "id", None):
|
||||
case "securityContact":
|
||||
|
|
|
@ -99,7 +99,7 @@ class TestDomainCache(MockEppLib):
|
|||
def test_cache_nested_elements_not_subdomain(self):
|
||||
"""Cache works correctly with the nested objects cache and hosts"""
|
||||
with less_console_noise():
|
||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov", state=Domain.State.DNS_NEEDED)
|
||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||
# The contact list will initially contain objects of type 'DomainContact'
|
||||
# this is then transformed into PublicContact, and cache should NOT
|
||||
# hold onto the DomainContact object
|
||||
|
@ -107,9 +107,9 @@ class TestDomainCache(MockEppLib):
|
|||
common.DomainContact(contact="123", type="security"),
|
||||
]
|
||||
expectedContactsDict = {
|
||||
PublicContact.ContactTypeChoices.ADMINISTRATIVE: None,
|
||||
PublicContact.ContactTypeChoices.SECURITY: "123",
|
||||
PublicContact.ContactTypeChoices.TECHNICAL: None,
|
||||
PublicContact.ContactTypeChoices.ADMINISTRATIVE: "adminContact",
|
||||
PublicContact.ContactTypeChoices.SECURITY: "securityContact",
|
||||
PublicContact.ContactTypeChoices.TECHNICAL: "technicalContact",
|
||||
}
|
||||
expectedHostsDict = {
|
||||
"name": self.mockDataInfoDomain.hosts[0],
|
||||
|
@ -129,6 +129,9 @@ 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)
|
||||
# print("!!! domain._cache[contacts] is", domain._cache["contacts"])
|
||||
# print("!!! expectedContactsDict is", expectedContactsDict)
|
||||
|
||||
self.assertEqual(domain._cache["contacts"], expectedContactsDict)
|
||||
|
||||
# get and check hosts is set correctly
|
||||
|
@ -206,15 +209,18 @@ class TestDomainCache(MockEppLib):
|
|||
domain, _ = Domain.objects.get_or_create(name="registry.gov", state=Domain.State.DNS_NEEDED)
|
||||
security = PublicContact.ContactTypeChoices.SECURITY
|
||||
mapped = domain.map_epp_contact_to_public_contact(
|
||||
self.mockDataInfoContact,
|
||||
self.mockDataInfoContact.id,
|
||||
self.mockDataSecurityContact,
|
||||
self.mockDataSecurityContact.id,
|
||||
security,
|
||||
)
|
||||
print("self.mockDataInfoContact.id is", self.mockDataInfoContact.id)
|
||||
print("self.mockDataSecurityContact.id is", self.mockDataSecurityContact.id)
|
||||
|
||||
# id and registry_id are the same thing
|
||||
expected_contact = PublicContact(
|
||||
domain=domain,
|
||||
contact_type=security,
|
||||
registry_id="123",
|
||||
registry_id="SECURITY", # self.mockDataInfoContact.id
|
||||
email="security@mail.gov",
|
||||
voice="+1.8882820870",
|
||||
fax="+1-212-9876543",
|
||||
|
@ -232,7 +238,8 @@ class TestDomainCache(MockEppLib):
|
|||
# two duplicate objects. We would expect
|
||||
# these not to have the same 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
|
||||
self.assertEqual(mapped.__dict__, expected_contact.__dict__)
|
||||
|
||||
|
@ -243,9 +250,16 @@ class TestDomainCache(MockEppLib):
|
|||
registry_id=domain.security_contact.registry_id,
|
||||
contact_type=security,
|
||||
).get()
|
||||
|
||||
"""
|
||||
!!! db_object is Registry Customer Service <123@mail.gov>id: 123 type: security
|
||||
!!! in_db is Registry Customer Service <security@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
|
||||
self.assertEqual(db_object, in_db)
|
||||
|
||||
domain.security_contact = in_db
|
||||
# Trigger the getter
|
||||
_ = domain.security_contact
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue