cleaned up noise in tests

This commit is contained in:
David Kennedy 2024-02-16 18:18:03 -05:00
parent 167634cc99
commit d56982ac26
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 1073 additions and 980 deletions

View file

@ -918,7 +918,6 @@ class DomainApplicationAdmin(ListHeaderAdmin):
"A rejection reason is required.",
)
else:
if obj.status != original_obj.status:
status_method_mapping = {

View file

@ -353,8 +353,14 @@ class DomainApplication(TimeStampedModel):
class RejectionReasons(models.TextChoices):
DOMAIN_PURPOSE = "domain_purpose", "Domain purpose requirements not met"
REQUESTOR = "requestor", "Requestor isn't authorized to make the request"
SECOND_DOMAIN_REASONING = "second_domain_reasoning", "Organization already has a domain and does not provide sufficient reasoning for a second domain"
CONTACTS_OR_ORGANIZATION_LEGITIMACY = "contacts_or_organization_legitimacy", "Research could not corroborate legitimacy of contacts or organization"
SECOND_DOMAIN_REASONING = (
"second_domain_reasoning",
"Organization already has a domain and does not provide sufficient reasoning for a second domain",
)
CONTACTS_OR_ORGANIZATION_LEGITIMACY = (
"contacts_or_organization_legitimacy",
"Research could not corroborate legitimacy of contacts or organization",
)
ORGANIZATION_ELIGIBILITY = "organization_eligibility", "Organization isn't eligible for a .gov"
NAMING_REQUIREMENTS = "naming_requirements", "Naming requirements not met"

View file

@ -270,6 +270,7 @@ class TestDomainApplicationAdminForm(TestCase):
self.application = completed_application()
def test_form_choices(self):
with less_console_noise():
# Create a form instance with the test application
form = DomainApplicationAdminForm(instance=self.application)
@ -278,6 +279,7 @@ class TestDomainApplicationAdminForm(TestCase):
self.assertEqual(form.fields["status"].widget.choices, expected_choices)
def test_form_choices_when_no_instance(self):
with less_console_noise():
# Create a form instance without an instance
form = DomainApplicationAdminForm()
@ -292,6 +294,7 @@ class TestDomainApplicationAdminForm(TestCase):
)
def test_form_choices_when_ineligible(self):
with less_console_noise():
# Create a form instance with a domain application with ineligible status
ineligible_application = DomainApplication(status="ineligible")
@ -327,6 +330,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_domain_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -340,6 +344,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_submitter_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -370,6 +375,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_investigator_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -401,6 +407,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""
Make sure the short name is displaying in admin on the list page
"""
with less_console_noise():
self.client.force_login(self.superuser)
completed_application()
response = self.client.get("/admin/registrar/domainapplication/")
@ -431,6 +438,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""Helper method for the email test cases.
email_index is the index of the email in mock_client."""
with less_console_noise():
# Access the arguments passed to send_email
call_args = self.mock_client.EMAILS_SENT
kwargs = call_args[email_index]["kwargs"]
@ -453,6 +461,7 @@ class TestDomainApplicationAdmin(MockEppLib):
When transitioning to submitted from dns needed or in review on a domain request,
no email is sent out."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -500,6 +509,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to approved on a domain request,
an email is sent out every time."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -513,7 +523,11 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.DOMAIN_PURPOSE)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.DOMAIN_PURPOSE,
)
self.assert_email_is_accurate("Your .gov domain request has been rejected.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -525,6 +539,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is domain purpose."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -533,8 +548,16 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason DOMAIN_PURPOSE and test email
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.DOMAIN_PURPOSE)
self.assert_email_is_accurate("Your domain request was rejected because the purpose you provided did not meet our \nrequirements.", 0, EMAIL)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.DOMAIN_PURPOSE,
)
self.assert_email_is_accurate(
"Your domain request was rejected because the purpose you provided did not meet our \nrequirements.",
0,
EMAIL,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -546,6 +569,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is requestor."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -554,8 +578,15 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason REQUESTOR and test email including dynamic organization name
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.REQUESTOR)
self.assert_email_is_accurate("Your domain request was rejected because we dont believe youre eligible to request a .gov domain on behalf of Testorg", 0, EMAIL)
self.transition_state_and_send_email(
application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.REQUESTOR
)
self.assert_email_is_accurate(
"Your domain request was rejected because we dont believe youre eligible to request a .gov domain "
"on behalf of Testorg",
0,
EMAIL,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -563,10 +594,11 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
def test_save_model_sends_rejected_email_requestor(self):
def test_save_model_sends_rejected_email_second_domain_reasoning(self):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is second domain."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -575,8 +607,14 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason SECOND_DOMAIN_REASONING and test email including dynamic organization name
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.SECOND_DOMAIN_REASONING)
self.assert_email_is_accurate("Your domain request was rejected because Testorg has a .gov domain.", 0, EMAIL)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.SECOND_DOMAIN_REASONING,
)
self.assert_email_is_accurate(
"Your domain request was rejected because Testorg has a .gov domain.", 0, EMAIL
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -588,6 +626,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is contacts or org legitimacy."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -596,8 +635,17 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason CONTACTS_OR_ORGANIZATION_LEGITIMACY and test email including dynamic organization name
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.CONTACTS_OR_ORGANIZATION_LEGITIMACY)
self.assert_email_is_accurate("Your domain request was rejected because we could not verify the organizational \ncontacts you provided. If you have questions or comments, reply to this email.", 0, EMAIL)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.CONTACTS_OR_ORGANIZATION_LEGITIMACY,
)
self.assert_email_is_accurate(
"Your domain request was rejected because we could not verify the organizational \n"
"contacts you provided. If you have questions or comments, reply to this email.",
0,
EMAIL,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -609,6 +657,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is org eligibility."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -617,8 +666,17 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason ORGANIZATION_ELIGIBILITY and test email including dynamic organization name
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.ORGANIZATION_ELIGIBILITY)
self.assert_email_is_accurate("Your domain request was rejected because we determined that Testorg is not \neligible for a .gov domain.", 0, EMAIL)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.ORGANIZATION_ELIGIBILITY,
)
self.assert_email_is_accurate(
"Your domain request was rejected because we determined that Testorg is not \neligible for "
"a .gov domain.",
0,
EMAIL,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -630,6 +688,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is naming."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -638,8 +697,14 @@ class TestDomainApplicationAdmin(MockEppLib):
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
# Reject for reason NAMING_REQUIREMENTS and test email including dynamic organization name
self.transition_state_and_send_email(application, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.NAMING_REQUIREMENTS)
self.assert_email_is_accurate("Your domain request was rejected because it does not meet our naming requirements.", 0, EMAIL)
self.transition_state_and_send_email(
application,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.NAMING_REQUIREMENTS,
)
self.assert_email_is_accurate(
"Your domain request was rejected because it does not meet our naming requirements.", 0, EMAIL
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
@ -654,6 +719,7 @@ class TestDomainApplicationAdmin(MockEppLib):
The transition fails.
"""
with less_console_noise():
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
# Create a request object with a superuser
@ -681,6 +747,7 @@ class TestDomainApplicationAdmin(MockEppLib):
The transition is successful.
"""
with less_console_noise():
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
# Create a request object with a superuser
@ -699,27 +766,11 @@ class TestDomainApplicationAdmin(MockEppLib):
application.refresh_from_db()
self.assertEqual(application.status, DomainApplication.ApplicationStatus.REJECTED)
def test_save_model_clear_rejected_reason(self):
"""When transitioning from rejected on a domain request,
the rejected_reason is cleared."""
# Create a sample application
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
application.rejected_reason = DomainApplication.RejectionReasons.DOMAIN_PURPOSE
application.save()
# Approve
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
application.approve()
application.refresh_from_db()
self.assertEqual(application.rejected_reason, None)
def test_save_model_sends_withdrawn_email(self):
"""When transitioning to withdrawn on a domain request,
an email is sent out every time."""
with less_console_noise():
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -745,6 +796,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_save_model_sets_approved_domain(self):
# make sure there is no user with this email
with less_console_noise():
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -766,6 +818,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.requested_domain.name, application.approved_domain.name)
def test_save_model_sets_restricted_status_on_user(self):
with less_console_noise():
# make sure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -777,7 +830,6 @@ class TestDomainApplicationAdmin(MockEppLib):
request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk))
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
# Modify the application's property
application.status = DomainApplication.ApplicationStatus.INELIGIBLE
@ -788,9 +840,9 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.creator.status, "restricted")
def test_readonly_when_restricted_creator(self):
with less_console_noise():
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED
application.creator.save()
@ -840,6 +892,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_analyst(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path
request.user = self.staffuser
@ -861,6 +914,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_superuser(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path
request.user = self.superuser
@ -871,10 +925,10 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields)
def test_saving_when_restricted_creator(self):
with less_console_noise():
# Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED
application.creator.save()
@ -896,10 +950,10 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW)
def test_change_view_with_restricted_creator(self):
with less_console_noise():
# Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED
application.creator.save()
@ -923,6 +977,7 @@ class TestDomainApplicationAdmin(MockEppLib):
Used to test errors when saving a change with an active domain, also used to test side effects
when saving a change goes through."""
with less_console_noise():
# Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
domain = Domain.objects.create(name=application.requested_domain.name)
@ -988,7 +1043,11 @@ class TestDomainApplicationAdmin(MockEppLib):
self.trigger_saving_approved_to_another_state(False, DomainApplication.ApplicationStatus.ACTION_NEEDED)
def test_side_effects_when_saving_approved_to_rejected(self):
self.trigger_saving_approved_to_another_state(False, DomainApplication.ApplicationStatus.REJECTED, DomainApplication.RejectionReasons.CONTACTS_OR_ORGANIZATION_LEGITIMACY)
self.trigger_saving_approved_to_another_state(
False,
DomainApplication.ApplicationStatus.REJECTED,
DomainApplication.RejectionReasons.CONTACTS_OR_ORGANIZATION_LEGITIMACY,
)
def test_side_effects_when_saving_approved_to_ineligible(self):
self.trigger_saving_approved_to_another_state(False, DomainApplication.ApplicationStatus.INELIGIBLE)
@ -1000,6 +1059,7 @@ class TestDomainApplicationAdmin(MockEppLib):
It retrieves the current list of filters from DomainApplicationAdmin
and checks that it matches the expected list of filters.
"""
with less_console_noise():
request = self.factory.get("/")
request.user = self.superuser
@ -1019,6 +1079,7 @@ class TestDomainApplicationAdmin(MockEppLib):
that it matches the expected queryset,
which is sorted alphabetically by the 'requested_domain__name' field.
"""
with less_console_noise():
# Creates a list of DomainApplications in scrambled order
multiple_unalphabetical_domain_objects("application")
@ -1051,6 +1112,7 @@ class TestDomainApplicationAdmin(MockEppLib):
the filter displays correctly, when the filter isn't filtering correctly.
"""
with less_console_noise():
# Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -1094,6 +1156,8 @@ class TestDomainApplicationAdmin(MockEppLib):
It then retrieves the queryset for the 'investigator' dropdown from DomainApplicationAdmin
and checks that it matches the expected queryset, which only includes staff users.
"""
with less_console_noise():
# Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -1128,6 +1192,7 @@ class TestDomainApplicationAdmin(MockEppLib):
This test verifies that filter list for the 'investigator'
is displayed alphabetically
"""
with less_console_noise():
# Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -1184,6 +1249,7 @@ class DomainInvitationAdminTest(TestCase):
def test_get_filters(self):
"""Ensures that our filters are displaying correctly"""
with less_console_noise():
# Have to get creative to get past linter
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1261,6 +1327,7 @@ class TestDomainInformationAdmin(TestCase):
User.objects.all().delete()
def test_readonly_fields_for_analyst(self):
with less_console_noise():
"""Ensures that analysts have their permissions setup correctly"""
request = self.factory.get("/")
request.user = self.staffuser
@ -1283,6 +1350,7 @@ class TestDomainInformationAdmin(TestCase):
def test_domain_sortable(self):
"""Tests if DomainInformation sorts by domain correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1294,6 +1362,7 @@ class TestDomainInformationAdmin(TestCase):
def test_submitter_sortable(self):
"""Tests if DomainInformation sorts by submitter correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1331,6 +1400,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_domain_sortable(self):
"""Tests if the UserDomainrole sorts by domain correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1352,6 +1422,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_user_sortable(self):
"""Tests if the UserDomainrole sorts by user correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1374,6 +1445,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_email_not_in_search(self):
"""Tests the search bar in Django Admin for UserDomainRoleAdmin.
Should return no results for an invalid email."""
with less_console_noise():
# Have to get creative to get past linter
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1406,6 +1478,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_email_in_search(self):
"""Tests the search bar in Django Admin for UserDomainRoleAdmin.
Should return results for an valid email."""
with less_console_noise():
# Have to get creative to get past linter
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1515,6 +1588,7 @@ class MyUserAdminTest(TestCase):
self.admin = MyUserAdmin(model=get_user_model(), admin_site=admin_site)
def test_list_display_without_username(self):
with less_console_noise():
request = self.client.request().wsgi_request
request.user = create_user()
@ -1531,6 +1605,7 @@ class MyUserAdminTest(TestCase):
self.assertNotIn("username", list_display)
def test_get_fieldsets_superuser(self):
with less_console_noise():
request = self.client.request().wsgi_request
request.user = create_superuser()
fieldsets = self.admin.get_fieldsets(request)
@ -1538,6 +1613,7 @@ class MyUserAdminTest(TestCase):
self.assertEqual(fieldsets, expected_fieldsets)
def test_get_fieldsets_cisa_analyst(self):
with less_console_noise():
request = self.client.request().wsgi_request
request.user = create_user()
fieldsets = self.admin.get_fieldsets(request)
@ -1571,6 +1647,7 @@ class AuditedAdminTest(TestCase):
return ordered_list
def test_alphabetically_sorted_fk_fields_domain_application(self):
with less_console_noise():
tested_fields = [
DomainApplication.authorizing_official.field,
DomainApplication.submitter.field,
@ -1627,6 +1704,7 @@ class AuditedAdminTest(TestCase):
)
def test_alphabetically_sorted_fk_fields_domain_information(self):
with less_console_noise():
tested_fields = [
DomainInformation.authorizing_official.field,
DomainInformation.submitter.field,
@ -1686,6 +1764,7 @@ class AuditedAdminTest(TestCase):
)
def test_alphabetically_sorted_fk_fields_domain_invitation(self):
with less_console_noise():
tested_fields = [DomainInvitation.domain.field]
# Creates multiple domain applications - review status does not matter
@ -1759,6 +1838,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_vars_set_correctly(self):
"""Checks if session variables are being set correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1774,6 +1854,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_vars_set_correctly_hardcoded_domain(self):
"""Checks if session variables are being set correctly"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1788,6 +1869,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_reset_correctly(self):
"""Checks if incorrect session variables get overridden"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1805,6 +1887,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_retain_information(self):
"""Checks to see if session variables retain old information"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1819,6 +1902,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_concurrent_requests(self):
"""Simulates two requests at once"""
with less_console_noise():
p = "adminpass"
self.client.login(username="superuser", password=p)
@ -1878,6 +1962,7 @@ class ContactAdminTest(TestCase):
self.staffuser = create_user()
def test_readonly_when_restricted_staffuser(self):
with less_console_noise():
request = self.factory.get("/")
request.user = self.staffuser
@ -1890,6 +1975,7 @@ class ContactAdminTest(TestCase):
self.assertEqual(readonly_fields, expected_fields)
def test_readonly_when_restricted_superuser(self):
with less_console_noise():
request = self.factory.get("/")
request.user = self.superuser
@ -1903,6 +1989,7 @@ class ContactAdminTest(TestCase):
"""Create a contact, join it to 4 domain requests. The 5th join will be a user.
Assert that the warning on the contact form lists 5 joins."""
with less_console_noise():
self.client.force_login(self.superuser)
# Create an instance of the model
@ -1984,6 +2071,7 @@ class VerifiedByStaffAdminTestCase(TestCase):
self.factory = RequestFactory()
def test_save_model_sets_user_field(self):
with less_console_noise():
self.client.force_login(self.superuser)
# Create an instance of the admin class