mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 05:54:11 +02:00
Even more unit testing
Almost done with it!
This commit is contained in:
parent
d60ff23020
commit
3b4e470f0c
1 changed files with 59 additions and 1 deletions
|
@ -314,7 +314,6 @@ class TestDomainApplication(TestCase):
|
||||||
except TransitionNotAllowed:
|
except TransitionNotAllowed:
|
||||||
self.fail("TransitionNotAllowed was raised, but it was not expected.")
|
self.fail("TransitionNotAllowed was raised, but it was not expected.")
|
||||||
|
|
||||||
|
|
||||||
def test_submit_transition_allowed_twice(self):
|
def test_submit_transition_allowed_twice(self):
|
||||||
"""
|
"""
|
||||||
Test that rotating between submit and in_review doesn't throw an error
|
Test that rotating between submit and in_review doesn't throw an error
|
||||||
|
@ -603,6 +602,30 @@ class TestDomainApplication(TestCase):
|
||||||
except TransitionNotAllowed:
|
except TransitionNotAllowed:
|
||||||
self.fail("TransitionNotAllowed was raised, but it was not expected.")
|
self.fail("TransitionNotAllowed was raised, but it was not expected.")
|
||||||
|
|
||||||
|
def test_withdraw_transition_allowed_with_investigator_not_staff(self):
|
||||||
|
"""
|
||||||
|
Tests for attempting to transition when investigator is not staff.
|
||||||
|
For withdraw, this should be valid in all cases.
|
||||||
|
"""
|
||||||
|
|
||||||
|
test_cases = [
|
||||||
|
(self.submitted_application, TransitionNotAllowed),
|
||||||
|
(self.in_review_application, TransitionNotAllowed),
|
||||||
|
(self.action_needed_application, TransitionNotAllowed),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Set all investigators to a user with no staff privs
|
||||||
|
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||||
|
set_applications_investigators(self.all_applications, user)
|
||||||
|
|
||||||
|
with boto3_mocking.clients.handler_for("sesv2", self.mock_client), less_console_noise():
|
||||||
|
for application, exception_type in test_cases:
|
||||||
|
with self.subTest(application=application, exception_type=exception_type):
|
||||||
|
try:
|
||||||
|
application.withdraw()
|
||||||
|
except TransitionNotAllowed:
|
||||||
|
self.fail("TransitionNotAllowed was raised, but it was not expected.")
|
||||||
|
|
||||||
def test_withdraw_transition_not_allowed(self):
|
def test_withdraw_transition_not_allowed(self):
|
||||||
"""
|
"""
|
||||||
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
||||||
|
@ -652,6 +675,23 @@ class TestDomainApplication(TestCase):
|
||||||
|
|
||||||
self.assert_fsm_transition_raises_error(test_cases, "reject")
|
self.assert_fsm_transition_raises_error(test_cases, "reject")
|
||||||
|
|
||||||
|
def test_reject_transition_not_allowed_with_investigator_not_staff(self):
|
||||||
|
"""
|
||||||
|
Tests for attempting to transition when investigator is not staff
|
||||||
|
"""
|
||||||
|
|
||||||
|
test_cases = [
|
||||||
|
(self.in_review_application, TransitionNotAllowed),
|
||||||
|
(self.action_needed_application, TransitionNotAllowed),
|
||||||
|
(self.approved_application, TransitionNotAllowed),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Set all investigators to a user with no staff privs
|
||||||
|
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||||
|
set_applications_investigators(self.all_applications, user)
|
||||||
|
|
||||||
|
self.assert_fsm_transition_raises_error(test_cases, "reject")
|
||||||
|
|
||||||
def test_reject_transition_not_allowed(self):
|
def test_reject_transition_not_allowed(self):
|
||||||
"""
|
"""
|
||||||
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
||||||
|
@ -703,6 +743,24 @@ class TestDomainApplication(TestCase):
|
||||||
|
|
||||||
self.assert_fsm_transition_raises_error(test_cases, "reject_with_prejudice")
|
self.assert_fsm_transition_raises_error(test_cases, "reject_with_prejudice")
|
||||||
|
|
||||||
|
def test_reject_with_prejudice_not_allowed_with_investigator_not_staff(self):
|
||||||
|
"""
|
||||||
|
Tests for attempting to transition when investigator is not staff
|
||||||
|
"""
|
||||||
|
|
||||||
|
test_cases = [
|
||||||
|
(self.in_review_application, TransitionNotAllowed),
|
||||||
|
(self.action_needed_application, TransitionNotAllowed),
|
||||||
|
(self.approved_application, TransitionNotAllowed),
|
||||||
|
(self.rejected_application, TransitionNotAllowed),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Set all investigators to a user with no staff privs
|
||||||
|
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||||
|
set_applications_investigators(self.all_applications, user)
|
||||||
|
|
||||||
|
self.assert_fsm_transition_raises_error(test_cases, "reject_with_prejudice")
|
||||||
|
|
||||||
def test_reject_with_prejudice_transition_not_allowed(self):
|
def test_reject_with_prejudice_transition_not_allowed(self):
|
||||||
"""
|
"""
|
||||||
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
Test that calling action_needed against transition rules raises TransitionNotAllowed.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue