updated test_admin

This commit is contained in:
David Kennedy 2024-07-05 12:46:10 -04:00
parent e338a73249
commit 0cfa59fa6b
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 23 additions and 13 deletions

View file

@ -41,6 +41,7 @@ from registrar.models.user_domain_role import UserDomainRole
from registrar.models.utility.contact_error import ContactError, ContactErrorCodes from registrar.models.utility.contact_error import ContactError, ContactErrorCodes
from api.tests.common import less_console_noise_decorator
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -525,6 +526,7 @@ class AuditedAdminMockData:
class MockDb(TestCase): class MockDb(TestCase):
@less_console_noise_decorator
def setUp(self): def setUp(self):
super().setUp() super().setUp()
username = "test_user" username = "test_user"

View file

@ -66,6 +66,7 @@ class TestFsmModelResource(TestCase):
def setUp(self): def setUp(self):
self.resource = FsmModelResource() self.resource = FsmModelResource()
@less_console_noise_decorator
def test_init_instance(self): def test_init_instance(self):
"""Test initializing an instance of a class with a FSM field""" """Test initializing an instance of a class with a FSM field"""
@ -80,6 +81,7 @@ class TestFsmModelResource(TestCase):
self.assertIsInstance(instance, Domain) self.assertIsInstance(instance, Domain)
self.assertEqual(instance.state, "ready") self.assertEqual(instance.state, "ready")
@less_console_noise_decorator
def test_import_field(self): def test_import_field(self):
"""Test that importing a field does not import FSM field""" """Test that importing a field does not import FSM field"""
@ -106,6 +108,7 @@ class TestFsmModelResource(TestCase):
class TestDomainRequestAdminForm(TestCase): class TestDomainRequestAdminForm(TestCase):
@less_console_noise_decorator
def setUp(self): def setUp(self):
# Create a test domain request with an initial state of started # Create a test domain request with an initial state of started
self.domain_request = completed_domain_request() self.domain_request = completed_domain_request()
@ -171,6 +174,7 @@ class TestDomainRequestAdminForm(TestCase):
class TestDomainInvitationAdmin(TestCase): class TestDomainInvitationAdmin(TestCase):
"""Tests for the DomainInvitation page""" """Tests for the DomainInvitation page"""
@less_console_noise_decorator
def setUp(self): def setUp(self):
"""Create a client object""" """Create a client object"""
self.client = Client(HTTP_HOST="localhost:8080") self.client = Client(HTTP_HOST="localhost:8080")
@ -296,6 +300,7 @@ class TestHostAdmin(TestCase):
class TestDomainInformationAdmin(TestCase): class TestDomainInformationAdmin(TestCase):
@less_console_noise_decorator
def setUp(self): def setUp(self):
"""Setup environment for a mock admin user""" """Setup environment for a mock admin user"""
self.site = AdminSite() self.site = AdminSite()
@ -958,21 +963,20 @@ class TestMyUserAdmin(MockDb):
@less_console_noise_decorator @less_console_noise_decorator
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 = self.staffuser
request.user = self.staffuser
list_display = self.admin.get_list_display(request) list_display = self.admin.get_list_display(request)
expected_list_display = [ expected_list_display = [
"email", "email",
"first_name", "first_name",
"last_name", "last_name",
"group", "group",
"status", "status",
] ]
self.assertEqual(list_display, expected_list_display) self.assertEqual(list_display, expected_list_display)
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(): with less_console_noise():
@ -1004,6 +1008,7 @@ class TestMyUserAdmin(MockDb):
) )
self.assertEqual(fieldsets, expected_fieldsets) self.assertEqual(fieldsets, expected_fieldsets)
@less_console_noise_decorator
def test_analyst_can_see_related_domains_and_requests_in_user_form(self): def test_analyst_can_see_related_domains_and_requests_in_user_form(self):
"""Tests if an analyst can see the related domains and domain requests for a user in that user's form""" """Tests if an analyst can see the related domains and domain requests for a user in that user's form"""
@ -1123,6 +1128,7 @@ class AuditedAdminTest(TestCase):
return ordered_list return ordered_list
@less_console_noise_decorator
def test_alphabetically_sorted_domain_request_investigator(self): def test_alphabetically_sorted_domain_request_investigator(self):
"""Tests if the investigator field is alphabetically sorted by mimicking """Tests if the investigator field is alphabetically sorted by mimicking
the call event flow""" the call event flow"""

View file

@ -1,6 +1,7 @@
from django.test import TestCase, Client from django.test import TestCase, Client
from django.urls import reverse from django.urls import reverse
from registrar.tests.common import create_superuser from registrar.tests.common import create_superuser
from api.tests.common import less_console_noise_decorator
class TestAdminViews(TestCase): class TestAdminViews(TestCase):
@ -8,6 +9,7 @@ class TestAdminViews(TestCase):
self.client = Client(HTTP_HOST="localhost:8080") self.client = Client(HTTP_HOST="localhost:8080")
self.superuser = create_superuser() self.superuser = create_superuser()
@less_console_noise_decorator
def test_export_data_view(self): def test_export_data_view(self):
self.client.force_login(self.superuser) self.client.force_login(self.superuser)