mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 18:25:58 +02:00
Add unit tests
This commit is contained in:
parent
d1fcb922c6
commit
883595ba44
2 changed files with 12 additions and 3 deletions
|
@ -158,7 +158,7 @@ class User(AbstractUser):
|
||||||
Given pre-existing data from TransitionDomain, VerifiedByStaff, and DomainInvitation,
|
Given pre-existing data from TransitionDomain, VerifiedByStaff, and DomainInvitation,
|
||||||
set the verification "type" defined in VerificationTypeChoices.
|
set the verification "type" defined in VerificationTypeChoices.
|
||||||
"""
|
"""
|
||||||
email_or_username = self.email or self.username
|
email_or_username = self.email if self.email else self.username
|
||||||
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
|
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
|
||||||
verification_type = self.get_verification_type_from_email(email_or_username, invitation_status=retrieved)
|
verification_type = self.get_verification_type_from_email(email_or_username, invitation_status=retrieved)
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class User(AbstractUser):
|
||||||
|
|
||||||
# If you joined BEFORE the oldest invitation was created, then you were verified normally.
|
# If you joined BEFORE the oldest invitation was created, then you were verified normally.
|
||||||
# (See logic in get_verification_type_from_email)
|
# (See logic in get_verification_type_from_email)
|
||||||
if self.date_joined < invitation.created_at:
|
if invitation is not None and self.date_joined < invitation.created_at:
|
||||||
verification_type = User.VerificationTypeChoices.REGULAR
|
verification_type = User.VerificationTypeChoices.REGULAR
|
||||||
|
|
||||||
self.verification_type = verification_type
|
self.verification_type = verification_type
|
||||||
|
|
|
@ -58,13 +58,21 @@ class TestPopulateVerificationType(MockEppLib):
|
||||||
)
|
)
|
||||||
self.grandfathered_user, _ = User.objects.get_or_create(username="grandpa@igormail.gov")
|
self.grandfathered_user, _ = User.objects.get_or_create(username="grandpa@igormail.gov")
|
||||||
|
|
||||||
invited, _ = DomainInvitation.objects.get_or_create(email="invited@igormail.gov", domain=self.domain_1)
|
invited, _ = DomainInvitation.objects.get_or_create(
|
||||||
|
email="invited@igormail.gov", domain=self.domain_1, status=DomainInvitation.DomainInvitationStatus.RETRIEVED
|
||||||
|
)
|
||||||
self.invited_user, _ = User.objects.get_or_create(username="invited@igormail.gov")
|
self.invited_user, _ = User.objects.get_or_create(username="invited@igormail.gov")
|
||||||
|
|
||||||
self.untouched_user, _ = User.objects.get_or_create(
|
self.untouched_user, _ = User.objects.get_or_create(
|
||||||
username="iaminvincible@igormail.gov", verification_type=User.VerificationTypeChoices.GRANDFATHERED
|
username="iaminvincible@igormail.gov", verification_type=User.VerificationTypeChoices.GRANDFATHERED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Fixture users should be untouched by the script. These will auto update once the
|
||||||
|
# user logs in / creates an account.
|
||||||
|
self.fixture_user, _ = User.objects.get_or_create(
|
||||||
|
username="fixture@igormail.gov", verification_type=User.VerificationTypeChoices.FIXTURE_USER
|
||||||
|
)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Deletes all DB objects related to migrations"""
|
"""Deletes all DB objects related to migrations"""
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
@ -112,6 +120,7 @@ class TestPopulateVerificationType(MockEppLib):
|
||||||
self.assertEqual(self.invited_user.verification_type, User.VerificationTypeChoices.INVITED)
|
self.assertEqual(self.invited_user.verification_type, User.VerificationTypeChoices.INVITED)
|
||||||
self.assertEqual(self.verified_by_staff_user.verification_type, User.VerificationTypeChoices.VERIFIED_BY_STAFF)
|
self.assertEqual(self.verified_by_staff_user.verification_type, User.VerificationTypeChoices.VERIFIED_BY_STAFF)
|
||||||
self.assertEqual(self.untouched_user.verification_type, User.VerificationTypeChoices.GRANDFATHERED)
|
self.assertEqual(self.untouched_user.verification_type, User.VerificationTypeChoices.GRANDFATHERED)
|
||||||
|
self.assertEqual(self.fixture_user.verification_type, User.VerificationTypeChoices.FIXTURE_USER)
|
||||||
|
|
||||||
|
|
||||||
class TestPopulateOrganizationType(MockEppLib):
|
class TestPopulateOrganizationType(MockEppLib):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue