Unit tests

This commit is contained in:
zandercymatics 2024-04-23 14:17:08 -06:00
parent 54b615d7f8
commit d1fcb922c6
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 103 additions and 8 deletions

View file

@ -158,13 +158,18 @@ class User(AbstractUser):
Given pre-existing data from TransitionDomain, VerifiedByStaff, and DomainInvitation,
set the verification "type" defined in VerificationTypeChoices.
"""
email_or_username = self.email or self.username
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved)
verification_type = self.get_verification_type_from_email(email_or_username, invitation_status=retrieved)
# An existing user may have been invited to a domain after they got verified.
# We need to check for this condition.
if verification_type == User.VerificationTypeChoices.INVITED:
invitation = DomainInvitation.objects.filter(email=self.email, status=retrieved).order_by("created_at").first()
invitation = (
DomainInvitation.objects.filter(email=email_or_username, status=retrieved)
.order_by("created_at")
.first()
)
# If you joined BEFORE the oldest invitation was created, then you were verified normally.
# (See logic in get_verification_type_from_email)