mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
last test for messages in dja
This commit is contained in:
parent
e3e001fe0d
commit
6d0b9d1a9e
2 changed files with 24 additions and 9 deletions
|
@ -55,6 +55,7 @@ from .common import (
|
|||
MockDbForSharedTests,
|
||||
AuditedAdminMockData,
|
||||
completed_domain_request,
|
||||
create_test_user,
|
||||
generic_domain_object,
|
||||
less_console_noise,
|
||||
mock_user,
|
||||
|
@ -1079,6 +1080,7 @@ class TestUserPortfolioPermissionAdmin(TestCase):
|
|||
"""Create a client object"""
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.superuser = create_superuser()
|
||||
self.testuser = create_test_user()
|
||||
self.portfolio = Portfolio.objects.create(organization_name="Test Portfolio", creator=self.superuser)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -1111,6 +1113,21 @@ class TestUserPortfolioPermissionAdmin(TestCase):
|
|||
"If you add someone to a portfolio here, it will not trigger an invitation email.",
|
||||
)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_delete_confirmation_page_contains_static_message(self):
|
||||
"""Ensure the custom message appears in the delete confirmation page."""
|
||||
self.client.force_login(self.superuser)
|
||||
# Create a test portfolio permission
|
||||
self.permission = UserPortfolioPermission.objects.create(
|
||||
user=self.testuser, portfolio=self.portfolio, roles=["organization_member"]
|
||||
)
|
||||
delete_url = reverse("admin:registrar_userportfoliopermission_delete", args=[self.permission.pk])
|
||||
response = self.client.get(delete_url)
|
||||
|
||||
# Check if the response contains the expected static message
|
||||
expected_message = "If you remove someone from a portfolio here, it will not send any emails"
|
||||
self.assertIn(expected_message, response.content.decode("utf-8"))
|
||||
|
||||
|
||||
class TestPortfolioInvitationAdmin(TestCase):
|
||||
"""Tests for the PortfolioInvitationAdmin class as super user
|
||||
|
@ -1555,19 +1572,16 @@ class TestPortfolioInvitationAdmin(TestCase):
|
|||
self.client.force_login(self.superuser)
|
||||
# Create a test portfolio invitation
|
||||
self.invitation = PortfolioInvitation.objects.create(
|
||||
email="testuser@example.com",
|
||||
portfolio=self.portfolio,
|
||||
roles=["organization_member"]
|
||||
)
|
||||
delete_url = reverse(
|
||||
"admin:registrar_portfolioinvitation_delete", args=[self.invitation.pk]
|
||||
email="testuser@example.com", portfolio=self.portfolio, roles=["organization_member"]
|
||||
)
|
||||
delete_url = reverse("admin:registrar_portfolioinvitation_delete", args=[self.invitation.pk])
|
||||
response = self.client.get(delete_url)
|
||||
|
||||
# Check if the response contains the expected static message
|
||||
expected_message = "If you cancel the portfolio invitation here"
|
||||
self.assertIn(expected_message, response.content.decode("utf-8"))
|
||||
|
||||
|
||||
class TestHostAdmin(TestCase):
|
||||
"""Tests for the HostAdmin class as super user
|
||||
|
||||
|
|
|
@ -1896,7 +1896,9 @@ class TestPortfolioMemberDeleteView(WebTest):
|
|||
@override_flag("organization_members", active=True)
|
||||
@patch("registrar.views.portfolios.send_portfolio_admin_removal_emails")
|
||||
@patch("registrar.views.portfolios.send_portfolio_member_permission_remove_email")
|
||||
def test_portfolio_member_table_delete_admin_success_removal_email_fail(self, send_member_removal, mock_send_removal_emails):
|
||||
def test_portfolio_member_table_delete_admin_success_removal_email_fail(
|
||||
self, send_member_removal, mock_send_removal_emails
|
||||
):
|
||||
"""Success state with deleting on Members Table page bc no active request AND
|
||||
not only admin. Because admin, removal emails are sent, but fail to send.
|
||||
Email to removed member also fails to send."""
|
||||
|
@ -1957,7 +1959,7 @@ class TestPortfolioMemberDeleteView(WebTest):
|
|||
self.assertEqual(called_kwargs["email"], member_email)
|
||||
self.assertEqual(called_kwargs["requestor"], self.user)
|
||||
self.assertEqual(called_kwargs["portfolio"], self.portfolio)
|
||||
|
||||
|
||||
# Get the arguments passed to send_portfolio_member_permission_remove_email
|
||||
_, called_kwargs = send_member_removal.call_args
|
||||
|
||||
|
@ -1966,7 +1968,6 @@ class TestPortfolioMemberDeleteView(WebTest):
|
|||
self.assertEqual(called_kwargs["permissions"].user, upp.user)
|
||||
self.assertEqual(called_kwargs["permissions"].portfolio, upp.portfolio)
|
||||
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("organization_feature", active=True)
|
||||
@override_flag("organization_members", active=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue