mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-27 21:16:28 +02:00
Sanity tests
This commit is contained in:
parent
029415974a
commit
c902d08aae
1 changed files with 55 additions and 0 deletions
|
@ -16,6 +16,7 @@ from registrar.models.domain_information import DomainInformation
|
||||||
from registrar.models.draft_domain import DraftDomain
|
from registrar.models.draft_domain import DraftDomain
|
||||||
from registrar.models.public_contact import PublicContact
|
from registrar.models.public_contact import PublicContact
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
|
from registrar.models.utility.contact_error import ContactError, ContactErrorCodes
|
||||||
from .common import MockEppLib
|
from .common import MockEppLib
|
||||||
from django_fsm import TransitionNotAllowed # type: ignore
|
from django_fsm import TransitionNotAllowed # type: ignore
|
||||||
from epplibwrapper import (
|
from epplibwrapper import (
|
||||||
|
@ -193,6 +194,60 @@ class TestDomainCache(MockEppLib):
|
||||||
self.assertEqual(cached_contact, in_db.registry_id)
|
self.assertEqual(cached_contact, in_db.registry_id)
|
||||||
self.assertEqual(domain.security_contact.email, "123test@mail.gov")
|
self.assertEqual(domain.security_contact.email, "123test@mail.gov")
|
||||||
|
|
||||||
|
def test_errors_map_epp_contact_to_public_contact(self):
|
||||||
|
"""
|
||||||
|
Scenario: Registrant gets invalid data from EPPLib
|
||||||
|
When the `map_epp_contact_to_public_contact` function
|
||||||
|
gets invalid data from EPPLib
|
||||||
|
Then the function throws the expected ContactErrors
|
||||||
|
"""
|
||||||
|
domain, _ = Domain.objects.get_or_create(name="registry.gov")
|
||||||
|
fakedEpp = self.fakedEppObject()
|
||||||
|
invalid_length = fakedEpp.dummyInfoContactResultData(
|
||||||
|
"Cymaticsisasubsetofmodalvibrationalphenomena",
|
||||||
|
"lengthInvalid@mail.gov"
|
||||||
|
)
|
||||||
|
valid_object = fakedEpp.dummyInfoContactResultData(
|
||||||
|
"valid",
|
||||||
|
"valid@mail.gov"
|
||||||
|
)
|
||||||
|
|
||||||
|
desired_error = ContactErrorCodes.CONTACT_ID_INVALID_LENGTH
|
||||||
|
with self.assertRaises(ContactError) as context:
|
||||||
|
domain.map_epp_contact_to_public_contact(
|
||||||
|
invalid_length,
|
||||||
|
invalid_length.id,
|
||||||
|
PublicContact.ContactTypeChoices.SECURITY,
|
||||||
|
)
|
||||||
|
self.assertEqual(context.exception.code, desired_error)
|
||||||
|
|
||||||
|
desired_error = ContactErrorCodes.CONTACT_ID_NONE
|
||||||
|
with self.assertRaises(ContactError) as context:
|
||||||
|
domain.map_epp_contact_to_public_contact(
|
||||||
|
valid_object,
|
||||||
|
None,
|
||||||
|
PublicContact.ContactTypeChoices.SECURITY,
|
||||||
|
)
|
||||||
|
self.assertEqual(context.exception.code, desired_error)
|
||||||
|
|
||||||
|
desired_error = ContactErrorCodes.CONTACT_INVALID_TYPE
|
||||||
|
with self.assertRaises(ContactError) as context:
|
||||||
|
domain.map_epp_contact_to_public_contact(
|
||||||
|
"bad_object",
|
||||||
|
valid_object.id,
|
||||||
|
PublicContact.ContactTypeChoices.SECURITY,
|
||||||
|
)
|
||||||
|
self.assertEqual(context.exception.code, desired_error)
|
||||||
|
|
||||||
|
desired_error = ContactErrorCodes.CONTACT_TYPE_NONE
|
||||||
|
with self.assertRaises(ContactError) as context:
|
||||||
|
domain.map_epp_contact_to_public_contact(
|
||||||
|
valid_object,
|
||||||
|
valid_object.id,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
self.assertEqual(context.exception.code, desired_error)
|
||||||
|
|
||||||
|
|
||||||
class TestDomainCreation(MockEppLib):
|
class TestDomainCreation(MockEppLib):
|
||||||
"""Rule: An approved domain application must result in a domain"""
|
"""Rule: An approved domain application must result in a domain"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue