...test fixes (part 1)...

This commit is contained in:
CocoByte 2024-02-29 16:22:25 -07:00
parent 919aacfc23
commit b0ef577869
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
7 changed files with 91 additions and 91 deletions

View file

@ -17,9 +17,9 @@ class DomainInformation(TimeStampedModel):
"""A registrant's domain information for that domain, exported from """A registrant's domain information for that domain, exported from
DomainRequest. We use these field from DomainRequest with few exceptions DomainRequest. We use these field from DomainRequest with few exceptions
which are 'removed' via pop at the bottom of this file. Most of design for domain which are 'removed' via pop at the bottom of this file. Most of design for domain
management's user information are based on application, but we cannot change management's user information are based on domain_request, but we cannot change
the domain request once approved, so copying them that way we can make changes the domain request once approved, so copying them that way we can make changes
after its approved. Most fields here are copied from Application.""" after its approved. Most fields here are copied from DomainRequest."""
StateTerritoryChoices = DomainRequest.StateTerritoryChoices StateTerritoryChoices = DomainRequest.StateTerritoryChoices
@ -232,7 +232,7 @@ class DomainInformation(TimeStampedModel):
raise ValueError("The provided DomainRequest has no id") raise ValueError("The provided DomainRequest has no id")
# check if we have a record that corresponds with the domain # check if we have a record that corresponds with the domain
# application, if so short circuit the create # domain_request, if so short circuit the create
existing_domain_info = cls.objects.filter(domain_request__id=domain_request.id).first() existing_domain_info = cls.objects.filter(domain_request__id=domain_request.id).first()
if existing_domain_info: if existing_domain_info:
return existing_domain_info return existing_domain_info

View file

@ -50,7 +50,7 @@
This is controlled by the class `dja-form-placeholder` on the button. This is controlled by the class `dja-form-placeholder` on the button.
In addition, the modal element MUST be placed low in the DOM. The script loads slower on DJA than on other portions In addition, the modal element MUST be placed low in the DOM. The script loads slower on DJA than on other portions
of the application, so this means that it will briefly "populate", causing unintended visual effects. of the domain_request, so this means that it will briefly "populate", causing unintended visual effects.
{% endcomment %} {% endcomment %}
<div <div
class="usa-modal" class="usa-modal"

View file

@ -580,7 +580,7 @@ def completed_domain_request(
if has_anything_else: if has_anything_else:
domain_request_kwargs["anything_else"] = "There is more" domain_request_kwargs["anything_else"] = "There is more"
application, _ = DomainRequest.objects.get_or_create(**domain_request_kwargs) domain_request, _ = DomainRequest.objects.get_or_create(**domain_request_kwargs)
if has_other_contacts: if has_other_contacts:
domain_request.other_contacts.add(other) domain_request.other_contacts.add(other)

View file

@ -661,39 +661,39 @@ class TestDomainRequestAdmin(MockEppLib):
domain_request = completed_domain_request() domain_request = completed_domain_request()
# Test Submitted Status from started # Test Submitted Status from started
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, True) self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, True)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status # Test Withdrawn Status
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.WITHDRAWN) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate( self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL, True "Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL, True
) )
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (from withdrawn) # Test Submitted Status Again (from withdrawn)
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to IN_REVIEW # Move it to IN_REVIEW
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.IN_REVIEW) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Test Submitted Status Again from in IN_REVIEW, no new email should be sent # Test Submitted Status Again from in IN_REVIEW, no new email should be sent
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to IN_REVIEW # Move it to IN_REVIEW
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.IN_REVIEW) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to ACTION_NEEDED # Move it to ACTION_NEEDED
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.ACTION_NEEDED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.ACTION_NEEDED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Test Submitted Status Again from in ACTION_NEEDED, no new email should be sent # Test Submitted Status Again from in ACTION_NEEDED, no new email should be sent
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
@override_settings(IS_PRODUCTION=True) @override_settings(IS_PRODUCTION=True)
@ -718,40 +718,40 @@ class TestDomainRequestAdmin(MockEppLib):
domain_request = completed_domain_request() domain_request = completed_domain_request()
# Test Submitted Status from started # Test Submitted Status from started
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL) self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status # Test Withdrawn Status
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.WITHDRAWN) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate( self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL "Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL
) )
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (from withdrawn) # Test Submitted Status Again (from withdrawn)
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL) self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to IN_REVIEW # Move it to IN_REVIEW
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.IN_REVIEW) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Test Submitted Status Again from in IN_REVIEW, no new email should be sent # Test Submitted Status Again from in IN_REVIEW, no new email should be sent
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to IN_REVIEW # Move it to IN_REVIEW
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.IN_REVIEW) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.IN_REVIEW)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to ACTION_NEEDED # Move it to ACTION_NEEDED
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.ACTION_NEEDED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.ACTION_NEEDED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Test Submitted Status Again from in ACTION_NEEDED, no new email should be sent # Test Submitted Status Again from in ACTION_NEEDED, no new email should be sent
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
def test_save_model_sends_approved_email(self): def test_save_model_sends_approved_email(self):
@ -767,7 +767,7 @@ class TestDomainRequestAdmin(MockEppLib):
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Test Submitted Status # Test Submitted Status
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 0, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 0, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
@ -781,7 +781,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (No new email should be sent) # Test Submitted Status Again (No new email should be sent)
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
def test_save_model_sends_rejected_email_purpose_not_met(self): def test_save_model_sends_rejected_email_purpose_not_met(self):
@ -810,7 +810,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -828,7 +828,7 @@ class TestDomainRequestAdmin(MockEppLib):
# Reject for reason REQUESTOR and test email including dynamic organization name # Reject for reason REQUESTOR and test email including dynamic organization name
self.transition_state_and_send_email( self.transition_state_and_send_email(
application, DomainRequest.DomainRequestStatus.REJECTED, DomainRequest.RejectionReasons.REQUESTOR domain_request, DomainRequest.DomainRequestStatus.REJECTED, DomainRequest.RejectionReasons.REQUESTOR
) )
self.assert_email_is_accurate( self.assert_email_is_accurate(
"Your domain request was rejected because we dont believe youre eligible to request a \n.gov " "Your domain request was rejected because we dont believe youre eligible to request a \n.gov "
@ -839,7 +839,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -867,7 +867,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -898,7 +898,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -929,7 +929,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -957,7 +957,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -983,7 +983,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve # Approve
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.APPROVED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -1054,19 +1054,19 @@ class TestDomainRequestAdmin(MockEppLib):
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Test Submitted Status # Test Submitted Status
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.WITHDRAWN) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate( self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 0, EMAIL "Your .gov domain request has been withdrawn and will not be reviewed by our team.", 0, EMAIL
) )
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status # Test Withdrawn Status
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.SUBMITTED) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 1, EMAIL) self.assert_email_is_accurate("We received your .gov domain request.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (No new email should be sent) # Test Submitted Status Again (No new email should be sent)
self.transition_state_and_send_email(application, DomainRequest.DomainRequestStatus.WITHDRAWN) self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3) self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
def test_save_model_sets_approved_domain(self): def test_save_model_sets_approved_domain(self):

View file

@ -168,7 +168,7 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
# Perform the specified action # Perform the specified action
action_method = getattr(application, action) action_method = getattr(domain_request, action)
action_method() action_method()
# Check if an email was sent # Check if an email was sent
@ -182,42 +182,42 @@ class TestDomainRequest(TestCase):
def test_submit_from_started_sends_email(self): def test_submit_from_started_sends_email(self):
msg = "Create a domain request and submit it and see if email was sent." msg = "Create a domain request and submit it and see if email was sent."
domain_request = completed_domain_request() domain_request = completed_domain_request()
self.check_email_sent(application, msg, "submit", 1) self.check_email_sent(domain_request, msg, "submit", 1)
def test_submit_from_withdrawn_sends_email(self): def test_submit_from_withdrawn_sends_email(self):
msg = "Create a withdrawn application and submit it and see if email was sent." msg = "Create a withdrawn application and submit it and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.WITHDRAWN) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.WITHDRAWN)
self.check_email_sent(application, msg, "submit", 1) self.check_email_sent(domain_request, msg, "submit", 1)
def test_submit_from_action_needed_does_not_send_email(self): def test_submit_from_action_needed_does_not_send_email(self):
msg = "Create a domain request with ACTION_NEEDED status and submit it, check if email was not sent." msg = "Create a domain request with ACTION_NEEDED status and submit it, check if email was not sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.ACTION_NEEDED) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.ACTION_NEEDED)
self.check_email_sent(application, msg, "submit", 0) self.check_email_sent(domain_request, msg, "submit", 0)
def test_submit_from_in_review_does_not_send_email(self): def test_submit_from_in_review_does_not_send_email(self):
msg = "Create a withdrawn application and submit it and see if email was sent." msg = "Create a withdrawn application and submit it and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
self.check_email_sent(application, msg, "submit", 0) self.check_email_sent(domain_request, msg, "submit", 0)
def test_approve_sends_email(self): def test_approve_sends_email(self):
msg = "Create a domain request and approve it and see if email was sent." msg = "Create a domain request and approve it and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
self.check_email_sent(application, msg, "approve", 1) self.check_email_sent(domain_request, msg, "approve", 1)
def test_withdraw_sends_email(self): def test_withdraw_sends_email(self):
msg = "Create a domain request and withdraw it and see if email was sent." msg = "Create a domain request and withdraw it and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
self.check_email_sent(application, msg, "withdraw", 1) self.check_email_sent(domain_request, msg, "withdraw", 1)
def test_reject_sends_email(self): def test_reject_sends_email(self):
msg = "Create a domain request and reject it and see if email was sent." msg = "Create a domain request and reject it and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED)
self.check_email_sent(application, msg, "reject", 1) self.check_email_sent(domain_request, msg, "reject", 1)
def test_reject_with_prejudice_does_not_send_email(self): def test_reject_with_prejudice_does_not_send_email(self):
msg = "Create a domain request and reject it with prejudice and see if email was sent." msg = "Create a domain request and reject it with prejudice and see if email was sent."
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED) domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED)
self.check_email_sent(application, msg, "reject_with_prejudice", 0) self.check_email_sent(domain_request, msg, "reject_with_prejudice", 0)
def test_submit_transition_allowed(self): def test_submit_transition_allowed(self):
""" """
@ -232,8 +232,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.submit() domain_request.submit()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -252,8 +252,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.submit() domain_request.submit()
@ -271,8 +271,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.in_review() domain_request.in_review()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -290,8 +290,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.in_review() domain_request.in_review()
@ -306,8 +306,8 @@ class TestDomainRequest(TestCase):
(self.ineligible_domain_request, TransitionNotAllowed), (self.ineligible_domain_request, TransitionNotAllowed),
] ]
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.action_needed() domain_request.action_needed()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -324,8 +324,8 @@ class TestDomainRequest(TestCase):
(self.withdrawn_domain_request, TransitionNotAllowed), (self.withdrawn_domain_request, TransitionNotAllowed),
] ]
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.action_needed() domain_request.action_needed()
@ -342,8 +342,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.approve() domain_request.approve()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -375,8 +375,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.approve() domain_request.approve()
@ -392,8 +392,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.withdraw() domain_request.withdraw()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -413,8 +413,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.withdraw() domain_request.withdraw()
@ -430,8 +430,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.reject() domain_request.reject()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -451,8 +451,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.reject() domain_request.reject()
@ -469,8 +469,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
try: try:
domain_request.reject_with_prejudice() domain_request.reject_with_prejudice()
except TransitionNotAllowed: except TransitionNotAllowed:
@ -489,8 +489,8 @@ class TestDomainRequest(TestCase):
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
for application, exception_type in test_cases: for domain_request, exception_type in test_cases:
with self.subTest(application=application, exception_type=exception_type): with self.subTest(domain_request=domain_request, exception_type=exception_type):
with self.assertRaises(exception_type): with self.assertRaises(exception_type):
domain_request.reject_with_prejudice() domain_request.reject_with_prejudice()

View file

@ -463,7 +463,7 @@ class DomainRequestTests(TestWithUser, WebTest):
# check that any new pages are added to this test # check that any new pages are added to this test
self.assertEqual(num_pages, num_pages_tested) self.assertEqual(num_pages, num_pages_tested)
# This is the start of a test to check an existing application, it currently # This is the start of a test to check an existing domain_request, it currently
# does not work and results in errors as noted in: # does not work and results in errors as noted in:
# https://github.com/cisagov/getgov/pull/728 # https://github.com/cisagov/getgov/pull/728
@skip("WIP") @skip("WIP")
@ -883,7 +883,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy2@town.com", email="testy2@town.com",
phone="(555) 555 5557", phone="(555) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1017,7 +1017,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy3@town.com", email="testy3@town.com",
phone="(201) 555 5557", phone="(201) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1091,7 +1091,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy2@town.com", email="testy2@town.com",
phone="(201) 555 5557", phone="(201) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1168,7 +1168,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy2@town.com", email="testy2@town.com",
phone="(201) 555 5557", phone="(201) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1244,7 +1244,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy2@town.com", email="testy2@town.com",
phone="(201) 555 5557", phone="(201) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1319,7 +1319,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy-admin@town.com", email="testy-admin@town.com",
phone="(201) 555 5556", phone="(201) 555 5556",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1391,7 +1391,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy@town.com", email="testy@town.com",
phone="(201) 555 5555", phone="(201) 555 5555",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1457,7 +1457,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy@town.com", email="testy@town.com",
phone="(201) 555 5555", phone="(201) 555 5555",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1528,7 +1528,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy@town.com", email="testy@town.com",
phone="(201) 555 5555", phone="(201) 555 5555",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1593,7 +1593,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy@town.com", email="testy@town.com",
phone="(201) 555 5555", phone="(201) 555 5555",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",
@ -1935,7 +1935,7 @@ class DomainRequestTests(TestWithUser, WebTest):
email="testy2@town.com", email="testy2@town.com",
phone="(555) 555 5557", phone="(555) 555 5557",
) )
application, _ = DomainRequest.objects.get_or_create( domain_request, _ = DomainRequest.objects.get_or_create(
organization_type="federal", organization_type="federal",
federal_type="executive", federal_type="executive",
purpose="Purpose of the site", purpose="Purpose of the site",

View file

@ -122,7 +122,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
return "wizard_domain_request" return "wizard_domain_request"
@property @property
def application(self) -> DomainRequest: def domain_request(self) -> DomainRequest:
""" """
Attempt to match the current wizard with a DomainRequest. Attempt to match the current wizard with a DomainRequest.
@ -194,8 +194,8 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
in the database before the wizard has been saved. in the database before the wizard has been saved.
""" """
if self.has_pk(): if self.has_pk():
if hasattr(self.application, attribute): if hasattr(self.domain_request, attribute):
attr = getattr(self.application, attribute) attr = getattr(self.domain_request, attribute)
if callable(attr): if callable(attr):
return attr(*args, **kwargs) return attr(*args, **kwargs)
else: else:
@ -278,7 +278,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
kwargs = { kwargs = {
"files": files, "files": files,
"prefix": self.steps.current, "prefix": self.steps.current,
"domain_request": self.application, # this is a property, not an object "domain_request": self.domain_request, # this is a property, not an object
} }
if step is None: if step is None:
@ -290,7 +290,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
instantiated = [] instantiated = []
for form in forms: for form in forms:
data = form.from_database(self.application) if self.has_pk() else None data = form.from_database(self.domain_request) if self.has_pk() else None
if use_post: if use_post:
instantiated.append(form(self.request.POST, **kwargs)) instantiated.append(form(self.request.POST, **kwargs))
elif use_db: elif use_db:
@ -466,7 +466,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
""" """
for form in forms: for form in forms:
if form is not None and hasattr(form, "to_database"): if form is not None and hasattr(form, "to_database"):
form.to_database(self.application) form.to_database(self.domain_request)
class OrganizationType(DomainRequestWizard): class OrganizationType(DomainRequestWizard):
@ -597,7 +597,7 @@ class Review(DomainRequestWizard):
def get_context_data(self): def get_context_data(self):
context = super().get_context_data() context = super().get_context_data()
context["Step"] = Step.__members__ context["Step"] = Step.__members__
context["domain_request"] = self.application context["domain_request"] = self.domain_request
return context return context
def goto_next_step(self): def goto_next_step(self):
@ -702,7 +702,7 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView):
# This determines if any of these three fields share a contact, which is used for # This determines if any of these three fields share a contact, which is used for
# the edge case where the same user may be an AO, and a submitter, for example. # the edge case where the same user may be an AO, and a submitter, for example.
if len(duplicates) > 0: if len(duplicates) > 0:
duplicates_to_delete, _ = self._get_orphaned_contacts(application, check_db=True) duplicates_to_delete, _ = self._get_orphaned_contacts(domain_request, check_db=True)
Contact.objects.filter(id__in=duplicates_to_delete, user=None).delete() Contact.objects.filter(id__in=duplicates_to_delete, user=None).delete()
return response return response