Fix remaining tests (hopefully)

This commit is contained in:
zandercymatics 2024-08-23 14:45:44 -06:00
parent 9f6d1324d9
commit 056df7151d
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
9 changed files with 28 additions and 41 deletions

View file

@ -35,21 +35,17 @@ class AllowedEmail(TimeStampedModel):
# Check if there's a '+' in the local part
if "+" in local:
base_local = local.split("+")[0]
base_email_exists = cls.objects.filter(
Q(email__iexact=f"{base_local}@{domain}")
).exists()
base_email_exists = cls.objects.filter(Q(email__iexact=f"{base_local}@{domain}")).exists()
# Given an example email, such as "joe.smoe+1@igorville.com"
# The full regex statement will be: "^joe.smoe\\+\\d+@igorville.com$"
pattern = f'^{re.escape(base_local)}\\+\\d+@{re.escape(domain)}$'
pattern = f"^{re.escape(base_local)}\\+\\d+@{re.escape(domain)}$"
return base_email_exists and re.match(pattern, email)
else:
# Edge case, the +1 record exists but the base does not,
# and the record we are checking is the base record.
pattern = f'^{re.escape(local)}\\+\\d+@{re.escape(domain)}$'
plus_email_exists = cls.objects.filter(
Q(email__iregex=pattern)
).exists()
pattern = f"^{re.escape(local)}\\+\\d+@{re.escape(domain)}$"
plus_email_exists = cls.objects.filter(Q(email__iregex=pattern)).exists()
return plus_email_exists
def __str__(self):

View file

@ -580,14 +580,8 @@ class DomainRequest(TimeStampedModel):
@classmethod
def get_statuses_that_send_emails(cls):
"""Returns a list of statuses that send an email to the user"""
excluded_statuses = [
cls.DomainRequestStatus.INELIGIBLE,
cls.DomainRequestStatus.IN_REVIEW
]
return [
status for status in cls.DomainRequestStatus
if status not in excluded_statuses
]
excluded_statuses = [cls.DomainRequestStatus.INELIGIBLE, cls.DomainRequestStatus.IN_REVIEW]
return [status for status in cls.DomainRequestStatus if status not in excluded_statuses]
def sync_organization_type(self):
"""