mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 18:56:15 +02:00
working on tests
This commit is contained in:
parent
6162a26ee9
commit
4df509c4f7
4 changed files with 29 additions and 13 deletions
|
@ -969,6 +969,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
Is the domain live on the inter webs?
|
Is the domain live on the inter webs?
|
||||||
could be replaced with request to see if ok status is set
|
could be replaced with request to see if ok status is set
|
||||||
"""
|
"""
|
||||||
|
return True
|
||||||
return self.state == self.State.READY
|
return self.state == self.State.READY
|
||||||
|
|
||||||
def is_editable(self) -> bool:
|
def is_editable(self) -> bool:
|
||||||
|
|
|
@ -25,6 +25,7 @@ from registrar.models import (
|
||||||
Portfolio,
|
Portfolio,
|
||||||
AllowedEmail,
|
AllowedEmail,
|
||||||
)
|
)
|
||||||
|
from registrar.utility.errors import FSMErrorCodes
|
||||||
from .common import (
|
from .common import (
|
||||||
MockSESClient,
|
MockSESClient,
|
||||||
completed_domain_request,
|
completed_domain_request,
|
||||||
|
@ -37,6 +38,7 @@ from .common import (
|
||||||
GenericTestHelper,
|
GenericTestHelper,
|
||||||
)
|
)
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
from django_fsm import TransitionNotAllowed
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import boto3_mocking # type: ignore
|
import boto3_mocking # type: ignore
|
||||||
|
@ -1796,18 +1798,10 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
|
|
||||||
domain_request.rejection_reason = rejection_reason
|
domain_request.rejection_reason = rejection_reason
|
||||||
|
|
||||||
self.admin.save_model(request, domain_request, None, True)
|
|
||||||
|
|
||||||
# Assert that the error message was called with the correct argument
|
|
||||||
if domain_is_active:
|
if domain_is_active:
|
||||||
messages.error.assert_called_once_with(
|
with self.assertRaises(TransitionNotAllowed):
|
||||||
request,
|
self.admin.save_model(request, domain_request, None, True)
|
||||||
"This action is not permitted. The domain " + "is already active.",
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
# Assert that the error message was never called
|
|
||||||
messages.error.assert_not_called()
|
|
||||||
|
|
||||||
self.assertEqual(domain_request.approved_domain, None)
|
self.assertEqual(domain_request.approved_domain, None)
|
||||||
|
|
||||||
# Assert that Domain got Deleted
|
# Assert that Domain got Deleted
|
||||||
|
@ -1818,6 +1812,27 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
with self.assertRaises(DomainInformation.DoesNotExist):
|
with self.assertRaises(DomainInformation.DoesNotExist):
|
||||||
domain_information.refresh_from_db()
|
domain_information.refresh_from_db()
|
||||||
|
|
||||||
|
|
||||||
|
# # Assert that the error message was called with the correct argument
|
||||||
|
# if domain_is_active:
|
||||||
|
# messages.error.assert_called_once_with(
|
||||||
|
# request,
|
||||||
|
# FSMErrorCodes.APPROVE_DOMAIN_IN_USE,
|
||||||
|
# )
|
||||||
|
# else:
|
||||||
|
# # Assert that the error message was never called
|
||||||
|
# messages.error.assert_not_called()
|
||||||
|
|
||||||
|
# self.assertEqual(domain_request.approved_domain, None)
|
||||||
|
|
||||||
|
# # Assert that Domain got Deleted
|
||||||
|
# with self.assertRaises(Domain.DoesNotExist):
|
||||||
|
# domain.refresh_from_db()
|
||||||
|
|
||||||
|
# # Assert that DomainInformation got Deleted
|
||||||
|
# with self.assertRaises(DomainInformation.DoesNotExist):
|
||||||
|
# domain_information.refresh_from_db()
|
||||||
|
|
||||||
def test_error_when_saving_approved_to_in_review_and_domain_is_active(self):
|
def test_error_when_saving_approved_to_in_review_and_domain_is_active(self):
|
||||||
self.trigger_saving_approved_to_another_state(True, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
self.trigger_saving_approved_to_another_state(True, DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from registrar.models import (
|
||||||
|
|
||||||
import boto3_mocking
|
import boto3_mocking
|
||||||
from registrar.utility.constants import BranchChoices
|
from registrar.utility.constants import BranchChoices
|
||||||
from registrar.utility.errors import FSMErrorCodes
|
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
MockSESClient,
|
MockSESClient,
|
||||||
|
@ -676,7 +676,7 @@ class TestDomainRequest(TestCase):
|
||||||
"""
|
"""
|
||||||
Domain.objects.all().create(name=self.submitted_domain_request.requested_domain.name)
|
Domain.objects.all().create(name=self.submitted_domain_request.requested_domain.name)
|
||||||
test_cases = [
|
test_cases = [
|
||||||
(self.submitted_domain_request, FSMErrorCodes.APPROVE_DOMAIN_IN_USE),
|
(self.submitted_domain_request, FSMDomainRequestError),
|
||||||
]
|
]
|
||||||
self.assert_fsm_transition_raises_error(test_cases, "approve")
|
self.assert_fsm_transition_raises_error(test_cases, "approve")
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FSMDomainRequestError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_error_mapping = {
|
_error_mapping = {
|
||||||
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("The domain name for this request is already in use. The name will need to be updated before this request can be approved."),
|
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("Cannot approve. Requested domain is already in use."),
|
||||||
FSMErrorCodes.NO_INVESTIGATOR: ("Investigator is required for this status."),
|
FSMErrorCodes.NO_INVESTIGATOR: ("Investigator is required for this status."),
|
||||||
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
|
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
|
||||||
FSMErrorCodes.NO_REJECTION_REASON: ("A reason is required for this status."),
|
FSMErrorCodes.NO_REJECTION_REASON: ("A reason is required for this status."),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue