fixed tests and cleaned up noise in existing tests

This commit is contained in:
David Kennedy 2024-02-16 12:41:15 -05:00
parent bd418c3dca
commit 4a3a72cfdd
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -68,9 +68,9 @@ class TestDomainAdmin(MockEppLib):
response = self.client.get("/admin/registrar/domain/") response = self.client.get("/admin/registrar/domain/")
# There are 3 template references to Federal (3) plus one reference in the table # There are 4 template references to Federal (4) plus four references in the table
# for our actual application # for our actual application
self.assertContains(response, "Federal", count=4) self.assertContains(response, "Federal", count=8)
# This may be a bit more robust # This may be a bit more robust
self.assertContains(response, '<td class="field-organization_type">Federal</td>', count=1) self.assertContains(response, '<td class="field-organization_type">Federal</td>', count=1)
# Now let's make sure the long description does not exist # Now let's make sure the long description does not exist
@ -270,6 +270,7 @@ class TestDomainApplicationAdminForm(TestCase):
self.application = completed_application() self.application = completed_application()
def test_form_choices(self): def test_form_choices(self):
with less_console_noise():
# Create a form instance with the test application # Create a form instance with the test application
form = DomainApplicationAdminForm(instance=self.application) form = DomainApplicationAdminForm(instance=self.application)
@ -278,6 +279,7 @@ class TestDomainApplicationAdminForm(TestCase):
self.assertEqual(form.fields["status"].widget.choices, expected_choices) self.assertEqual(form.fields["status"].widget.choices, expected_choices)
def test_form_choices_when_no_instance(self): def test_form_choices_when_no_instance(self):
with less_console_noise():
# Create a form instance without an instance # Create a form instance without an instance
form = DomainApplicationAdminForm() form = DomainApplicationAdminForm()
@ -292,6 +294,7 @@ class TestDomainApplicationAdminForm(TestCase):
) )
def test_form_choices_when_ineligible(self): def test_form_choices_when_ineligible(self):
with less_console_noise():
# Create a form instance with a domain application with ineligible status # Create a form instance with a domain application with ineligible status
ineligible_application = DomainApplication(status="ineligible") ineligible_application = DomainApplication(status="ineligible")
@ -327,6 +330,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_domain_sortable(self): def test_domain_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly""" """Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -340,6 +344,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_submitter_sortable(self): def test_submitter_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly""" """Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -352,7 +357,7 @@ class TestDomainApplicationAdmin(MockEppLib):
# Assert that our sort works correctly # Assert that our sort works correctly
self.test_helper.assert_table_sorted( self.test_helper.assert_table_sorted(
"5", "11",
( (
"submitter__first_name", "submitter__first_name",
"submitter__last_name", "submitter__last_name",
@ -361,7 +366,7 @@ class TestDomainApplicationAdmin(MockEppLib):
# Assert that sorting in reverse works correctly # Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted( self.test_helper.assert_table_sorted(
"-5", "-11",
( (
"-submitter__first_name", "-submitter__first_name",
"-submitter__last_name", "-submitter__last_name",
@ -370,6 +375,7 @@ class TestDomainApplicationAdmin(MockEppLib):
def test_investigator_sortable(self): def test_investigator_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly""" """Tests if the DomainApplication sorts by domain correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -401,12 +407,13 @@ class TestDomainApplicationAdmin(MockEppLib):
""" """
Make sure the short name is displaying in admin on the list page Make sure the short name is displaying in admin on the list page
""" """
with less_console_noise():
self.client.force_login(self.superuser) self.client.force_login(self.superuser)
completed_application() completed_application()
response = self.client.get("/admin/registrar/domainapplication/") response = self.client.get("/admin/registrar/domainapplication/")
# There are 3 template references to Federal (3) plus one reference in the table # There are 4 template references to Federal (4) plus two references in the table
# for our actual application # for our actual application
self.assertContains(response, "Federal", count=4) self.assertContains(response, "Federal", count=6)
# This may be a bit more robust # This may be a bit more robust
self.assertContains(response, '<td class="field-organization_type">Federal</td>', count=1) self.assertContains(response, '<td class="field-organization_type">Federal</td>', count=1)
# Now let's make sure the long description does not exist # Now let's make sure the long description does not exist
@ -430,6 +437,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""Helper method for the email test cases. """Helper method for the email test cases.
email_index is the index of the email in mock_client.""" email_index is the index of the email in mock_client."""
with less_console_noise():
# Access the arguments passed to send_email # Access the arguments passed to send_email
call_args = self.mock_client.EMAILS_SENT call_args = self.mock_client.EMAILS_SENT
kwargs = call_args[email_index]["kwargs"] kwargs = call_args[email_index]["kwargs"]
@ -452,6 +460,7 @@ class TestDomainApplicationAdmin(MockEppLib):
When transitioning to submitted from dns needed or in review on a domain request, When transitioning to submitted from dns needed or in review on a domain request,
no email is sent out.""" no email is sent out."""
with less_console_noise():
# Ensure there is no user with this email # Ensure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -499,6 +508,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to approved on a domain request, """When transitioning to approved on a domain request,
an email is sent out every time.""" an email is sent out every time."""
with less_console_noise():
# Ensure there is no user with this email # Ensure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -524,6 +534,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, """When transitioning to rejected on a domain request,
an email is sent out every time.""" an email is sent out every time."""
with less_console_noise():
# Ensure there is no user with this email # Ensure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -549,6 +560,7 @@ class TestDomainApplicationAdmin(MockEppLib):
"""When transitioning to withdrawn on a domain request, """When transitioning to withdrawn on a domain request,
an email is sent out every time.""" an email is sent out every time."""
with less_console_noise():
# Ensure there is no user with this email # Ensure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -573,6 +585,7 @@ class TestDomainApplicationAdmin(MockEppLib):
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):
with less_console_noise():
# make sure there is no user with this email # make sure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -584,7 +597,6 @@ class TestDomainApplicationAdmin(MockEppLib):
request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk)) request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk))
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
# Modify the application's property # Modify the application's property
application.status = DomainApplication.ApplicationStatus.APPROVED application.status = DomainApplication.ApplicationStatus.APPROVED
@ -595,6 +607,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.requested_domain.name, application.approved_domain.name) self.assertEqual(application.requested_domain.name, application.approved_domain.name)
def test_save_model_sets_restricted_status_on_user(self): def test_save_model_sets_restricted_status_on_user(self):
with less_console_noise():
# make sure there is no user with this email # make sure there is no user with this email
EMAIL = "mayor@igorville.gov" EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete() User.objects.filter(email=EMAIL).delete()
@ -606,7 +619,6 @@ class TestDomainApplicationAdmin(MockEppLib):
request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk)) request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk))
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
# Modify the application's property # Modify the application's property
application.status = DomainApplication.ApplicationStatus.INELIGIBLE application.status = DomainApplication.ApplicationStatus.INELIGIBLE
@ -617,9 +629,9 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.creator.status, "restricted") self.assertEqual(application.creator.status, "restricted")
def test_readonly_when_restricted_creator(self): def test_readonly_when_restricted_creator(self):
with less_console_noise():
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW) application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED application.creator.status = User.RESTRICTED
application.creator.save() application.creator.save()
@ -668,6 +680,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields) self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_analyst(self): def test_readonly_fields_for_analyst(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path request = self.factory.get("/") # Use the correct method and path
request.user = self.staffuser request.user = self.staffuser
@ -689,6 +702,7 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields) self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_superuser(self): def test_readonly_fields_for_superuser(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path request = self.factory.get("/") # Use the correct method and path
request.user = self.superuser request.user = self.superuser
@ -699,10 +713,10 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(readonly_fields, expected_fields) self.assertEqual(readonly_fields, expected_fields)
def test_saving_when_restricted_creator(self): def test_saving_when_restricted_creator(self):
with less_console_noise():
# Create an instance of the model # Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW) application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED application.creator.status = User.RESTRICTED
application.creator.save() application.creator.save()
@ -724,10 +738,10 @@ class TestDomainApplicationAdmin(MockEppLib):
self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW) self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW)
def test_change_view_with_restricted_creator(self): def test_change_view_with_restricted_creator(self):
with less_console_noise():
# Create an instance of the model # Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW) application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise():
application.creator.status = User.RESTRICTED application.creator.status = User.RESTRICTED
application.creator.save() application.creator.save()
@ -751,6 +765,7 @@ class TestDomainApplicationAdmin(MockEppLib):
Used to test errors when saving a change with an active domain, also used to test side effects Used to test errors when saving a change with an active domain, also used to test side effects
when saving a change goes through.""" when saving a change goes through."""
with less_console_noise():
# Create an instance of the model # Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED) application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
domain = Domain.objects.create(name=application.requested_domain.name) domain = Domain.objects.create(name=application.requested_domain.name)
@ -826,6 +841,7 @@ class TestDomainApplicationAdmin(MockEppLib):
It retrieves the current list of filters from DomainApplicationAdmin It retrieves the current list of filters from DomainApplicationAdmin
and checks that it matches the expected list of filters. and checks that it matches the expected list of filters.
""" """
with less_console_noise():
request = self.factory.get("/") request = self.factory.get("/")
request.user = self.superuser request.user = self.superuser
@ -845,6 +861,7 @@ class TestDomainApplicationAdmin(MockEppLib):
that it matches the expected queryset, that it matches the expected queryset,
which is sorted alphabetically by the 'requested_domain__name' field. which is sorted alphabetically by the 'requested_domain__name' field.
""" """
with less_console_noise():
# Creates a list of DomainApplications in scrambled order # Creates a list of DomainApplications in scrambled order
multiple_unalphabetical_domain_objects("application") multiple_unalphabetical_domain_objects("application")
@ -877,6 +894,7 @@ class TestDomainApplicationAdmin(MockEppLib):
the filter displays correctly, when the filter isn't filtering correctly. the filter displays correctly, when the filter isn't filtering correctly.
""" """
with less_console_noise():
# Create a mock DomainApplication object, with a fake investigator # Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy") application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get() investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -920,6 +938,7 @@ class TestDomainApplicationAdmin(MockEppLib):
It then retrieves the queryset for the 'investigator' dropdown from DomainApplicationAdmin It then retrieves the queryset for the 'investigator' dropdown from DomainApplicationAdmin
and checks that it matches the expected queryset, which only includes staff users. 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 # Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy") application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get() investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -954,6 +973,7 @@ class TestDomainApplicationAdmin(MockEppLib):
This test verifies that filter list for the 'investigator' This test verifies that filter list for the 'investigator'
is displayed alphabetically is displayed alphabetically
""" """
with less_console_noise():
# Create a mock DomainApplication object, with a fake investigator # Create a mock DomainApplication object, with a fake investigator
application: DomainApplication = generic_domain_object("application", "SomeGuy") application: DomainApplication = generic_domain_object("application", "SomeGuy")
investigator_user = User.objects.filter(username=application.investigator.username).get() investigator_user = User.objects.filter(username=application.investigator.username).get()
@ -1010,6 +1030,7 @@ class DomainInvitationAdminTest(TestCase):
def test_get_filters(self): def test_get_filters(self):
"""Ensures that our filters are displaying correctly""" """Ensures that our filters are displaying correctly"""
with less_console_noise():
# Have to get creative to get past linter # Have to get creative to get past linter
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1088,6 +1109,7 @@ class TestDomainInformationAdmin(TestCase):
def test_readonly_fields_for_analyst(self): def test_readonly_fields_for_analyst(self):
"""Ensures that analysts have their permissions setup correctly""" """Ensures that analysts have their permissions setup correctly"""
with less_console_noise():
request = self.factory.get("/") request = self.factory.get("/")
request.user = self.staffuser request.user = self.staffuser
@ -1109,6 +1131,7 @@ class TestDomainInformationAdmin(TestCase):
def test_domain_sortable(self): def test_domain_sortable(self):
"""Tests if DomainInformation sorts by domain correctly""" """Tests if DomainInformation sorts by domain correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1120,6 +1143,7 @@ class TestDomainInformationAdmin(TestCase):
def test_submitter_sortable(self): def test_submitter_sortable(self):
"""Tests if DomainInformation sorts by submitter correctly""" """Tests if DomainInformation sorts by submitter correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1157,6 +1181,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_domain_sortable(self): def test_domain_sortable(self):
"""Tests if the UserDomainrole sorts by domain correctly""" """Tests if the UserDomainrole sorts by domain correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1178,6 +1203,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_user_sortable(self): def test_user_sortable(self):
"""Tests if the UserDomainrole sorts by user correctly""" """Tests if the UserDomainrole sorts by user correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1200,6 +1226,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_email_not_in_search(self): def test_email_not_in_search(self):
"""Tests the search bar in Django Admin for UserDomainRoleAdmin. """Tests the search bar in Django Admin for UserDomainRoleAdmin.
Should return no results for an invalid email.""" Should return no results for an invalid email."""
with less_console_noise():
# Have to get creative to get past linter # Have to get creative to get past linter
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1232,6 +1259,7 @@ class UserDomainRoleAdminTest(TestCase):
def test_email_in_search(self): def test_email_in_search(self):
"""Tests the search bar in Django Admin for UserDomainRoleAdmin. """Tests the search bar in Django Admin for UserDomainRoleAdmin.
Should return results for an valid email.""" Should return results for an valid email."""
with less_console_noise():
# Have to get creative to get past linter # Have to get creative to get past linter
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1341,6 +1369,7 @@ class MyUserAdminTest(TestCase):
self.admin = MyUserAdmin(model=get_user_model(), admin_site=admin_site) self.admin = MyUserAdmin(model=get_user_model(), admin_site=admin_site)
def test_list_display_without_username(self): def test_list_display_without_username(self):
with less_console_noise():
request = self.client.request().wsgi_request request = self.client.request().wsgi_request
request.user = create_user() request.user = create_user()
@ -1357,6 +1386,7 @@ class MyUserAdminTest(TestCase):
self.assertNotIn("username", list_display) self.assertNotIn("username", list_display)
def test_get_fieldsets_superuser(self): def test_get_fieldsets_superuser(self):
with less_console_noise():
request = self.client.request().wsgi_request request = self.client.request().wsgi_request
request.user = create_superuser() request.user = create_superuser()
fieldsets = self.admin.get_fieldsets(request) fieldsets = self.admin.get_fieldsets(request)
@ -1364,6 +1394,7 @@ class MyUserAdminTest(TestCase):
self.assertEqual(fieldsets, expected_fieldsets) self.assertEqual(fieldsets, expected_fieldsets)
def test_get_fieldsets_cisa_analyst(self): def test_get_fieldsets_cisa_analyst(self):
with less_console_noise():
request = self.client.request().wsgi_request request = self.client.request().wsgi_request
request.user = create_user() request.user = create_user()
fieldsets = self.admin.get_fieldsets(request) fieldsets = self.admin.get_fieldsets(request)
@ -1386,6 +1417,7 @@ class AuditedAdminTest(TestCase):
self.client = Client(HTTP_HOST="localhost:8080") self.client = Client(HTTP_HOST="localhost:8080")
def order_by_desired_field_helper(self, obj_to_sort: AuditedAdmin, request, field_name, *obj_names): def order_by_desired_field_helper(self, obj_to_sort: AuditedAdmin, request, field_name, *obj_names):
with less_console_noise():
formatted_sort_fields = [] formatted_sort_fields = []
for obj in obj_names: for obj in obj_names:
formatted_sort_fields.append("{}__{}".format(field_name, obj)) formatted_sort_fields.append("{}__{}".format(field_name, obj))
@ -1397,6 +1429,7 @@ class AuditedAdminTest(TestCase):
return ordered_list return ordered_list
def test_alphabetically_sorted_fk_fields_domain_application(self): def test_alphabetically_sorted_fk_fields_domain_application(self):
with less_console_noise():
tested_fields = [ tested_fields = [
DomainApplication.authorizing_official.field, DomainApplication.authorizing_official.field,
DomainApplication.submitter.field, DomainApplication.submitter.field,
@ -1453,6 +1486,7 @@ class AuditedAdminTest(TestCase):
) )
def test_alphabetically_sorted_fk_fields_domain_information(self): def test_alphabetically_sorted_fk_fields_domain_information(self):
with less_console_noise():
tested_fields = [ tested_fields = [
DomainInformation.authorizing_official.field, DomainInformation.authorizing_official.field,
DomainInformation.submitter.field, DomainInformation.submitter.field,
@ -1512,6 +1546,7 @@ class AuditedAdminTest(TestCase):
) )
def test_alphabetically_sorted_fk_fields_domain_invitation(self): def test_alphabetically_sorted_fk_fields_domain_invitation(self):
with less_console_noise():
tested_fields = [DomainInvitation.domain.field] tested_fields = [DomainInvitation.domain.field]
# Creates multiple domain applications - review status does not matter # Creates multiple domain applications - review status does not matter
@ -1585,6 +1620,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_vars_set_correctly(self): def test_session_vars_set_correctly(self):
"""Checks if session variables are being set correctly""" """Checks if session variables are being set correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1600,6 +1636,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_vars_set_correctly_hardcoded_domain(self): def test_session_vars_set_correctly_hardcoded_domain(self):
"""Checks if session variables are being set correctly""" """Checks if session variables are being set correctly"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1614,6 +1651,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_reset_correctly(self): def test_session_variables_reset_correctly(self):
"""Checks if incorrect session variables get overridden""" """Checks if incorrect session variables get overridden"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1631,6 +1669,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_retain_information(self): def test_session_variables_retain_information(self):
"""Checks to see if session variables retain old information""" """Checks to see if session variables retain old information"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1645,6 +1684,7 @@ class DomainSessionVariableTest(TestCase):
def test_session_variables_concurrent_requests(self): def test_session_variables_concurrent_requests(self):
"""Simulates two requests at once""" """Simulates two requests at once"""
with less_console_noise():
p = "adminpass" p = "adminpass"
self.client.login(username="superuser", password=p) self.client.login(username="superuser", password=p)
@ -1704,6 +1744,7 @@ class ContactAdminTest(TestCase):
self.staffuser = create_user() self.staffuser = create_user()
def test_readonly_when_restricted_staffuser(self): def test_readonly_when_restricted_staffuser(self):
with less_console_noise():
request = self.factory.get("/") request = self.factory.get("/")
request.user = self.staffuser request.user = self.staffuser
@ -1716,6 +1757,7 @@ class ContactAdminTest(TestCase):
self.assertEqual(readonly_fields, expected_fields) self.assertEqual(readonly_fields, expected_fields)
def test_readonly_when_restricted_superuser(self): def test_readonly_when_restricted_superuser(self):
with less_console_noise():
request = self.factory.get("/") request = self.factory.get("/")
request.user = self.superuser request.user = self.superuser
@ -1728,7 +1770,7 @@ class ContactAdminTest(TestCase):
def test_change_view_for_joined_contact_five_or_less(self): def test_change_view_for_joined_contact_five_or_less(self):
"""Create a contact, join it to 4 domain requests. The 5th join will be a user. """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.""" Assert that the warning on the contact form lists 5 joins."""
with less_console_noise():
self.client.force_login(self.superuser) self.client.force_login(self.superuser)
# Create an instance of the model # Create an instance of the model
@ -1810,6 +1852,7 @@ class VerifiedByStaffAdminTestCase(TestCase):
self.factory = RequestFactory() self.factory = RequestFactory()
def test_save_model_sets_user_field(self): def test_save_model_sets_user_field(self):
with less_console_noise():
self.client.force_login(self.superuser) self.client.force_login(self.superuser)
# Create an instance of the admin class # Create an instance of the admin class