mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-20 03:19:24 +02:00
updated comments, updated test_models
This commit is contained in:
parent
bc75600202
commit
a2558bd762
5 changed files with 233 additions and 158 deletions
|
@ -181,7 +181,12 @@ class TestDomainRequestAdminForm(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestDomainInvitationAdmin(TestCase):
|
class TestDomainInvitationAdmin(TestCase):
|
||||||
"""Tests for the DomainInvitation page"""
|
"""Tests for the DomainInvitationAdmin class as super user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; do not change this model in tests
|
||||||
|
tests have available superuser, client, and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -246,6 +251,12 @@ class TestDomainInvitationAdmin(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestHostAdmin(TestCase):
|
class TestHostAdmin(TestCase):
|
||||||
|
"""Tests for the HostAdmin class as super user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; do not change this model in tests
|
||||||
|
tests have available superuser, client, and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -317,6 +328,12 @@ class TestHostAdmin(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestDomainInformationAdmin(TestCase):
|
class TestDomainInformationAdmin(TestCase):
|
||||||
|
"""Tests for the DomainInformationAdmin class as super or staff user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser/staffuser; do not change these models in tests
|
||||||
|
tests have available staffuser, superuser, client, test_helper and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -699,6 +716,12 @@ class TestDomainInformationAdmin(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestUserDomainRoleAdmin(TestCase):
|
class TestUserDomainRoleAdmin(TestCase):
|
||||||
|
"""Tests for the UserDomainRoleAdmin class as super user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; do not change this model in tests
|
||||||
|
tests have available superuser, client, test_helper and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -876,6 +899,12 @@ class TestUserDomainRoleAdmin(TestCase):
|
||||||
fake_user.delete()
|
fake_user.delete()
|
||||||
|
|
||||||
class TestListHeaderAdmin(TestCase):
|
class TestListHeaderAdmin(TestCase):
|
||||||
|
"""Tests for the ListHeaderAdmin class as super user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; do not change this model in tests
|
||||||
|
tests have available superuser, client and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -957,6 +986,13 @@ class TestListHeaderAdmin(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestMyUserAdmin(MockDbForSharedTests):
|
class TestMyUserAdmin(MockDbForSharedTests):
|
||||||
|
"""Tests for the MyUserAdmin class as super or staff user
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser/staffuser; do not change these models in tests
|
||||||
|
all tests share MockDb; do not change models defined therein in tests
|
||||||
|
tests have available staffuser, superuser, client, test_helper and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
|
|
@ -36,6 +36,12 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TestDomainAdminAsStaff(MockEppLib):
|
class TestDomainAdminAsStaff(MockEppLib):
|
||||||
|
"""Test DomainAdmin class as staff user.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share staffuser; do not change staffuser model in tests
|
||||||
|
tests have available staffuser, client, and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
|
@ -367,6 +373,12 @@ class TestDomainAdminAsStaff(MockEppLib):
|
||||||
|
|
||||||
|
|
||||||
class TestDomainAdminWClient(TestCase):
|
class TestDomainAdminWClient(TestCase):
|
||||||
|
"""Test DomainAdmin class as super user.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; tests must not update superuser
|
||||||
|
tests have available superuser, client, and admin
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
|
@ -651,6 +663,14 @@ class TestDomainAdminWClient(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestDomainAdminWebTest(MockEppLib, WebTest):
|
class TestDomainAdminWebTest(MockEppLib, WebTest):
|
||||||
|
"""Test DomainAdmin class as super user, using WebTest.
|
||||||
|
WebTest allows for easier handling of forms and html responses.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser; tests must not update superuser
|
||||||
|
tests have available superuser, app, and admin
|
||||||
|
"""
|
||||||
|
|
||||||
# csrf checks do not work with WebTest.
|
# csrf checks do not work with WebTest.
|
||||||
# We disable them here. TODO for another ticket.
|
# We disable them here. TODO for another ticket.
|
||||||
csrf_checks = False
|
csrf_checks = False
|
||||||
|
|
|
@ -42,6 +42,12 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
class TestDomainRequestAdmin(MockEppLib):
|
class TestDomainRequestAdmin(MockEppLib):
|
||||||
|
"""Test DomainRequestAdmin class as either staff or super user.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
all tests share superuser/staffuser; do not change these models in tests
|
||||||
|
tests have available staffuser, superuser, client, admin and test_helper
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
|
@ -61,6 +67,20 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
)
|
)
|
||||||
self.mock_client = MockSESClient()
|
self.mock_client = MockSESClient()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super().tearDown()
|
||||||
|
Domain.objects.all().delete()
|
||||||
|
DomainInformation.objects.all().delete()
|
||||||
|
DomainRequest.objects.all().delete()
|
||||||
|
Contact.objects.all().delete()
|
||||||
|
Website.objects.all().delete()
|
||||||
|
self.mock_client.EMAILS_SENT.clear()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
super().tearDownClass()
|
||||||
|
User.objects.all().delete()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_has_model_description(self):
|
def test_has_model_description(self):
|
||||||
"""Tests if this model has a model description on the table view"""
|
"""Tests if this model has a model description on the table view"""
|
||||||
|
@ -1854,18 +1874,4 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
# Check if response contains expected_html
|
# Check if response contains expected_html
|
||||||
self.assertIn(expected_html, response_content)
|
self.assertIn(expected_html, response_content)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super().tearDown()
|
|
||||||
Domain.objects.all().delete()
|
|
||||||
DomainInformation.objects.all().delete()
|
|
||||||
DomainRequest.objects.all().delete()
|
|
||||||
Contact.objects.all().delete()
|
|
||||||
Website.objects.all().delete()
|
|
||||||
self.mock_client.EMAILS_SENT.clear()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(self):
|
|
||||||
super().tearDownClass()
|
|
||||||
User.objects.all().delete()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.db.utils import IntegrityError
|
from django.db.utils import IntegrityError
|
||||||
|
from django.db import transaction
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
@ -23,15 +24,12 @@ from registrar.models.transition_domain import TransitionDomain
|
||||||
from registrar.models.verified_by_staff import VerifiedByStaff # type: ignore
|
from registrar.models.verified_by_staff import VerifiedByStaff # type: ignore
|
||||||
from registrar.utility.constants import BranchChoices
|
from registrar.utility.constants import BranchChoices
|
||||||
|
|
||||||
from .common import MockSESClient, less_console_noise, completed_domain_request, set_domain_request_investigators
|
from .common import MockSESClient, less_console_noise, completed_domain_request, set_domain_request_investigators, create_test_user
|
||||||
from django_fsm import TransitionNotAllowed
|
from django_fsm import TransitionNotAllowed
|
||||||
from waffle.testutils import override_flag
|
from waffle.testutils import override_flag
|
||||||
|
|
||||||
from api.tests.common import less_console_noise_decorator
|
from api.tests.common import less_console_noise_decorator
|
||||||
|
|
||||||
# Test comment for push -- will remove
|
|
||||||
# The DomainRequest submit method has a side effect of sending an email
|
|
||||||
# with AWS SES, so mock that out in all of these test cases
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
class TestDomainRequest(TestCase):
|
class TestDomainRequest(TestCase):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -92,6 +90,11 @@ class TestDomainRequest(TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
DomainInformation.objects.all().delete()
|
||||||
|
DomainRequest.objects.all().delete()
|
||||||
|
DraftDomain.objects.all().delete()
|
||||||
|
Domain.objects.all().delete()
|
||||||
|
User.objects.all().delete()
|
||||||
self.mock_client.EMAILS_SENT.clear()
|
self.mock_client.EMAILS_SENT.clear()
|
||||||
|
|
||||||
def assertNotRaises(self, exception_type):
|
def assertNotRaises(self, exception_type):
|
||||||
|
@ -121,23 +124,22 @@ class TestDomainRequest(TestCase):
|
||||||
self.assertEqual(domain_request.federal_agency, expected_federal_agency)
|
self.assertEqual(domain_request.federal_agency, expected_federal_agency)
|
||||||
|
|
||||||
def test_empty_create_fails(self):
|
def test_empty_create_fails(self):
|
||||||
"""Can't create a completely empty domain request.
|
"""Can't create a completely empty domain request."""
|
||||||
NOTE: something about theexception this test raises messes up with the
|
|
||||||
atomic block in a custom tearDown method for the parent test class."""
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
|
with transaction.atomic():
|
||||||
with self.assertRaisesRegex(IntegrityError, "creator"):
|
with self.assertRaisesRegex(IntegrityError, "creator"):
|
||||||
DomainRequest.objects.create()
|
DomainRequest.objects.create()
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_minimal_create(self):
|
def test_minimal_create(self):
|
||||||
"""Can create with just a creator."""
|
"""Can create with just a creator."""
|
||||||
with less_console_noise():
|
|
||||||
user, _ = User.objects.get_or_create(username="testy")
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
domain_request = DomainRequest.objects.create(creator=user)
|
domain_request = DomainRequest.objects.create(creator=user)
|
||||||
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.STARTED)
|
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.STARTED)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_full_create(self):
|
def test_full_create(self):
|
||||||
"""Can create with all fields."""
|
"""Can create with all fields."""
|
||||||
with less_console_noise():
|
|
||||||
user, _ = User.objects.get_or_create(username="testy")
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
contact = Contact.objects.create()
|
contact = Contact.objects.create()
|
||||||
com_website, _ = Website.objects.get_or_create(website="igorville.com")
|
com_website, _ = Website.objects.get_or_create(website="igorville.com")
|
||||||
|
@ -166,9 +168,9 @@ class TestDomainRequest(TestCase):
|
||||||
domain_request.other_contacts.add(contact)
|
domain_request.other_contacts.add(contact)
|
||||||
domain_request.save()
|
domain_request.save()
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_domain_info(self):
|
def test_domain_info(self):
|
||||||
"""Can create domain info with all fields."""
|
"""Can create domain info with all fields."""
|
||||||
with less_console_noise():
|
|
||||||
user, _ = User.objects.get_or_create(username="testy")
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
contact = Contact.objects.create()
|
contact = Contact.objects.create()
|
||||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||||
|
@ -194,8 +196,8 @@ class TestDomainRequest(TestCase):
|
||||||
self.assertEqual(information.domain.id, domain.id)
|
self.assertEqual(information.domain.id, domain.id)
|
||||||
self.assertEqual(information.id, domain.domain_info.id)
|
self.assertEqual(information.id, domain.domain_info.id)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_status_fsm_submit_fail(self):
|
def test_status_fsm_submit_fail(self):
|
||||||
with less_console_noise():
|
|
||||||
user, _ = User.objects.get_or_create(username="testy")
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
domain_request = DomainRequest.objects.create(creator=user)
|
domain_request = DomainRequest.objects.create(creator=user)
|
||||||
|
|
||||||
|
@ -205,8 +207,8 @@ class TestDomainRequest(TestCase):
|
||||||
# can't submit a domain request with a null domain name
|
# can't submit a domain request with a null domain name
|
||||||
domain_request.submit()
|
domain_request.submit()
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_status_fsm_submit_succeed(self):
|
def test_status_fsm_submit_succeed(self):
|
||||||
with less_console_noise():
|
|
||||||
user, _ = User.objects.get_or_create(username="testy")
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
site = DraftDomain.objects.create(name="igorville.gov")
|
site = DraftDomain.objects.create(name="igorville.gov")
|
||||||
domain_request = DomainRequest.objects.create(creator=user, requested_domain=site)
|
domain_request = DomainRequest.objects.create(creator=user, requested_domain=site)
|
||||||
|
@ -218,6 +220,7 @@ class TestDomainRequest(TestCase):
|
||||||
domain_request.submit()
|
domain_request.submit()
|
||||||
self.assertEqual(domain_request.status, domain_request.DomainRequestStatus.SUBMITTED)
|
self.assertEqual(domain_request.status, domain_request.DomainRequestStatus.SUBMITTED)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def check_email_sent(
|
def check_email_sent(
|
||||||
self, domain_request, msg, action, expected_count, expected_content=None, expected_email="mayor@igorville.com"
|
self, domain_request, msg, action, expected_count, expected_content=None, expected_email="mayor@igorville.com"
|
||||||
):
|
):
|
||||||
|
@ -225,7 +228,6 @@ class TestDomainRequest(TestCase):
|
||||||
|
|
||||||
with self.subTest(msg=msg, action=action):
|
with self.subTest(msg=msg, action=action):
|
||||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||||
with less_console_noise():
|
|
||||||
# Perform the specified action
|
# Perform the specified action
|
||||||
action_method = getattr(domain_request, action)
|
action_method = getattr(domain_request, action)
|
||||||
action_method()
|
action_method()
|
||||||
|
@ -899,11 +901,11 @@ class TestDomainRequest(TestCase):
|
||||||
with self.assertRaises(TransitionNotAllowed):
|
with self.assertRaises(TransitionNotAllowed):
|
||||||
self.approved_domain_request.reject_with_prejudice()
|
self.approved_domain_request.reject_with_prejudice()
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_approve_from_rejected_clears_rejection_reason(self):
|
def test_approve_from_rejected_clears_rejection_reason(self):
|
||||||
"""When transitioning from rejected to approved on a domain request,
|
"""When transitioning from rejected to approved on a domain request,
|
||||||
the rejection_reason is cleared."""
|
the rejection_reason is cleared."""
|
||||||
|
|
||||||
with less_console_noise():
|
|
||||||
# Create a sample domain request
|
# Create a sample domain request
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
||||||
domain_request.rejection_reason = DomainRequest.RejectionReasons.DOMAIN_PURPOSE
|
domain_request.rejection_reason = DomainRequest.RejectionReasons.DOMAIN_PURPOSE
|
||||||
|
@ -915,11 +917,11 @@ class TestDomainRequest(TestCase):
|
||||||
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.APPROVED)
|
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.APPROVED)
|
||||||
self.assertEqual(domain_request.rejection_reason, None)
|
self.assertEqual(domain_request.rejection_reason, None)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_in_review_from_rejected_clears_rejection_reason(self):
|
def test_in_review_from_rejected_clears_rejection_reason(self):
|
||||||
"""When transitioning from rejected to in_review on a domain request,
|
"""When transitioning from rejected to in_review on a domain request,
|
||||||
the rejection_reason is cleared."""
|
the rejection_reason is cleared."""
|
||||||
|
|
||||||
with less_console_noise():
|
|
||||||
# Create a sample domain request
|
# Create a sample domain request
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
||||||
domain_request.domain_is_not_active = True
|
domain_request.domain_is_not_active = True
|
||||||
|
@ -932,11 +934,11 @@ class TestDomainRequest(TestCase):
|
||||||
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||||
self.assertEqual(domain_request.rejection_reason, None)
|
self.assertEqual(domain_request.rejection_reason, None)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_action_needed_from_rejected_clears_rejection_reason(self):
|
def test_action_needed_from_rejected_clears_rejection_reason(self):
|
||||||
"""When transitioning from rejected to action_needed on a domain request,
|
"""When transitioning from rejected to action_needed on a domain request,
|
||||||
the rejection_reason is cleared."""
|
the rejection_reason is cleared."""
|
||||||
|
|
||||||
with less_console_noise():
|
|
||||||
# Create a sample domain request
|
# Create a sample domain request
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.REJECTED)
|
||||||
domain_request.domain_is_not_active = True
|
domain_request.domain_is_not_active = True
|
||||||
|
@ -949,27 +951,27 @@ class TestDomainRequest(TestCase):
|
||||||
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.ACTION_NEEDED)
|
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.ACTION_NEEDED)
|
||||||
self.assertEqual(domain_request.rejection_reason, None)
|
self.assertEqual(domain_request.rejection_reason, None)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_has_rationale_returns_true(self):
|
def test_has_rationale_returns_true(self):
|
||||||
"""has_rationale() returns true when a domain request has no_other_contacts_rationale"""
|
"""has_rationale() returns true when a domain request has no_other_contacts_rationale"""
|
||||||
with less_console_noise():
|
|
||||||
self.started_domain_request.no_other_contacts_rationale = "You talkin' to me?"
|
self.started_domain_request.no_other_contacts_rationale = "You talkin' to me?"
|
||||||
self.started_domain_request.save()
|
self.started_domain_request.save()
|
||||||
self.assertEquals(self.started_domain_request.has_rationale(), True)
|
self.assertEquals(self.started_domain_request.has_rationale(), True)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_has_rationale_returns_false(self):
|
def test_has_rationale_returns_false(self):
|
||||||
"""has_rationale() returns false when a domain request has no no_other_contacts_rationale"""
|
"""has_rationale() returns false when a domain request has no no_other_contacts_rationale"""
|
||||||
with less_console_noise():
|
|
||||||
self.assertEquals(self.started_domain_request.has_rationale(), False)
|
self.assertEquals(self.started_domain_request.has_rationale(), False)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_has_other_contacts_returns_true(self):
|
def test_has_other_contacts_returns_true(self):
|
||||||
"""has_other_contacts() returns true when a domain request has other_contacts"""
|
"""has_other_contacts() returns true when a domain request has other_contacts"""
|
||||||
with less_console_noise():
|
|
||||||
# completed_domain_request has other contacts by default
|
# completed_domain_request has other contacts by default
|
||||||
self.assertEquals(self.started_domain_request.has_other_contacts(), True)
|
self.assertEquals(self.started_domain_request.has_other_contacts(), True)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
def test_has_other_contacts_returns_false(self):
|
def test_has_other_contacts_returns_false(self):
|
||||||
"""has_other_contacts() returns false when a domain request has no other_contacts"""
|
"""has_other_contacts() returns false when a domain request has no other_contacts"""
|
||||||
with less_console_noise():
|
|
||||||
domain_request = completed_domain_request(
|
domain_request = completed_domain_request(
|
||||||
status=DomainRequest.DomainRequestStatus.STARTED, name="no-others.gov", has_other_contacts=False
|
status=DomainRequest.DomainRequestStatus.STARTED, name="no-others.gov", has_other_contacts=False
|
||||||
)
|
)
|
||||||
|
@ -1072,8 +1074,13 @@ class TestInvitations(TestCase):
|
||||||
self.invitation, _ = DomainInvitation.objects.get_or_create(email=self.email, domain=self.domain)
|
self.invitation, _ = DomainInvitation.objects.get_or_create(email=self.email, domain=self.domain)
|
||||||
self.user, _ = User.objects.get_or_create(email=self.email)
|
self.user, _ = User.objects.get_or_create(email=self.email)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super().tearDown()
|
||||||
# clean out the roles each time
|
# clean out the roles each time
|
||||||
UserDomainRole.objects.all().delete()
|
UserDomainRole.objects.all().delete()
|
||||||
|
self.domain.delete()
|
||||||
|
self.invitation.delete()
|
||||||
|
User.objects.all().delete()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_retrieval_creates_role(self):
|
def test_retrieval_creates_role(self):
|
||||||
|
@ -1630,17 +1637,16 @@ class TestDomainInformationCustomSave(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestDomainRequestIncomplete(TestCase):
|
class TestDomainRequestIncomplete(TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.factory = RequestFactory()
|
||||||
|
cls.user = create_test_user()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.factory = RequestFactory()
|
|
||||||
username = "test_user"
|
|
||||||
first_name = "First"
|
|
||||||
last_name = "Last"
|
|
||||||
email = "info@example.com"
|
|
||||||
self.user = get_user_model().objects.create(
|
|
||||||
username=username, first_name=first_name, last_name=last_name, email=email
|
|
||||||
)
|
|
||||||
so, _ = Contact.objects.get_or_create(
|
so, _ = Contact.objects.get_or_create(
|
||||||
first_name="Meowy",
|
first_name="Meowy",
|
||||||
last_name="Meoward",
|
last_name="Meoward",
|
||||||
|
@ -1698,6 +1704,11 @@ class TestDomainRequestIncomplete(TestCase):
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
Contact.objects.all().delete()
|
Contact.objects.all().delete()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
super().tearDownClass()
|
||||||
|
cls.user.delete()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_is_federal_complete(self):
|
def test_is_federal_complete(self):
|
||||||
self.assertTrue(self.domain_request._is_federal_complete())
|
self.assertTrue(self.domain_request._is_federal_complete())
|
||||||
|
|
|
@ -8,6 +8,7 @@ from api.tests.common import less_console_noise_decorator
|
||||||
from registrar.models.contact import Contact
|
from registrar.models.contact import Contact
|
||||||
from registrar.models.domain import Domain
|
from registrar.models.domain import Domain
|
||||||
from registrar.models.draft_domain import DraftDomain
|
from registrar.models.draft_domain import DraftDomain
|
||||||
|
from registrar.models.federal_agency import FederalAgency
|
||||||
from registrar.models.portfolio import Portfolio
|
from registrar.models.portfolio import Portfolio
|
||||||
from registrar.models.public_contact import PublicContact
|
from registrar.models.public_contact import PublicContact
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
|
@ -988,16 +989,17 @@ class PortfoliosTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.user.save()
|
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
self.domain, _ = Domain.objects.get_or_create(name="sampledomain.gov", state=Domain.State.READY)
|
self.domain, _ = Domain.objects.get_or_create(name="sampledomain.gov", state=Domain.State.READY)
|
||||||
self.role, _ = UserDomainRole.objects.get_or_create(
|
self.role, _ = UserDomainRole.objects.get_or_create(
|
||||||
user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
|
user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
|
||||||
)
|
)
|
||||||
self.portfolio, _ = Portfolio.objects.get_or_create(creator=self.user, organization_name="xyz inc")
|
self.federal_agency = FederalAgency.objects.create()
|
||||||
|
self.portfolio, _ = Portfolio.objects.get_or_create(creator=self.user, organization_name="xyz inc", federal_agency=self.federal_agency)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
Portfolio.objects.all().delete()
|
Portfolio.objects.all().delete()
|
||||||
|
self.federal_agency.delete()
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
PublicContact.objects.filter(domain=self.domain).delete()
|
PublicContact.objects.filter(domain=self.domain).delete()
|
||||||
UserDomainRole.objects.all().delete()
|
UserDomainRole.objects.all().delete()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue