working on tests

This commit is contained in:
Rachid Mrad 2024-10-02 17:49:57 -04:00
parent 6162a26ee9
commit 4df509c4f7
No known key found for this signature in database
4 changed files with 29 additions and 13 deletions

View file

@ -25,6 +25,7 @@ from registrar.models import (
Portfolio,
AllowedEmail,
)
from registrar.utility.errors import FSMErrorCodes
from .common import (
MockSESClient,
completed_domain_request,
@ -37,6 +38,7 @@ from .common import (
GenericTestHelper,
)
from unittest.mock import patch
from django_fsm import TransitionNotAllowed
from django.conf import settings
import boto3_mocking # type: ignore
@ -1796,18 +1798,10 @@ class TestDomainRequestAdmin(MockEppLib):
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:
messages.error.assert_called_once_with(
request,
"This action is not permitted. The domain " + "is already active.",
)
with self.assertRaises(TransitionNotAllowed):
self.admin.save_model(request, domain_request, None, True)
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
@ -1818,6 +1812,27 @@ class TestDomainRequestAdmin(MockEppLib):
with self.assertRaises(DomainInformation.DoesNotExist):
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):
self.trigger_saving_approved_to_another_state(True, DomainRequest.DomainRequestStatus.IN_REVIEW)