mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-28 13:36:30 +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,
|
MockDbForSharedTests,
|
||||||
AuditedAdminMockData,
|
AuditedAdminMockData,
|
||||||
completed_domain_request,
|
completed_domain_request,
|
||||||
|
create_test_user,
|
||||||
generic_domain_object,
|
generic_domain_object,
|
||||||
less_console_noise,
|
less_console_noise,
|
||||||
mock_user,
|
mock_user,
|
||||||
|
@ -1079,6 +1080,7 @@ class TestUserPortfolioPermissionAdmin(TestCase):
|
||||||
"""Create a client object"""
|
"""Create a client object"""
|
||||||
self.client = Client(HTTP_HOST="localhost:8080")
|
self.client = Client(HTTP_HOST="localhost:8080")
|
||||||
self.superuser = create_superuser()
|
self.superuser = create_superuser()
|
||||||
|
self.testuser = create_test_user()
|
||||||
self.portfolio = Portfolio.objects.create(organization_name="Test Portfolio", creator=self.superuser)
|
self.portfolio = Portfolio.objects.create(organization_name="Test Portfolio", creator=self.superuser)
|
||||||
|
|
||||||
def tearDown(self):
|
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.",
|
"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):
|
class TestPortfolioInvitationAdmin(TestCase):
|
||||||
"""Tests for the PortfolioInvitationAdmin class as super user
|
"""Tests for the PortfolioInvitationAdmin class as super user
|
||||||
|
@ -1555,19 +1572,16 @@ class TestPortfolioInvitationAdmin(TestCase):
|
||||||
self.client.force_login(self.superuser)
|
self.client.force_login(self.superuser)
|
||||||
# Create a test portfolio invitation
|
# Create a test portfolio invitation
|
||||||
self.invitation = PortfolioInvitation.objects.create(
|
self.invitation = PortfolioInvitation.objects.create(
|
||||||
email="testuser@example.com",
|
email="testuser@example.com", portfolio=self.portfolio, roles=["organization_member"]
|
||||||
portfolio=self.portfolio,
|
|
||||||
roles=["organization_member"]
|
|
||||||
)
|
|
||||||
delete_url = reverse(
|
|
||||||
"admin:registrar_portfolioinvitation_delete", args=[self.invitation.pk]
|
|
||||||
)
|
)
|
||||||
|
delete_url = reverse("admin:registrar_portfolioinvitation_delete", args=[self.invitation.pk])
|
||||||
response = self.client.get(delete_url)
|
response = self.client.get(delete_url)
|
||||||
|
|
||||||
# Check if the response contains the expected static message
|
# Check if the response contains the expected static message
|
||||||
expected_message = "If you cancel the portfolio invitation here"
|
expected_message = "If you cancel the portfolio invitation here"
|
||||||
self.assertIn(expected_message, response.content.decode("utf-8"))
|
self.assertIn(expected_message, response.content.decode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
class TestHostAdmin(TestCase):
|
class TestHostAdmin(TestCase):
|
||||||
"""Tests for the HostAdmin class as super user
|
"""Tests for the HostAdmin class as super user
|
||||||
|
|
||||||
|
|
|
@ -1896,7 +1896,9 @@ class TestPortfolioMemberDeleteView(WebTest):
|
||||||
@override_flag("organization_members", active=True)
|
@override_flag("organization_members", active=True)
|
||||||
@patch("registrar.views.portfolios.send_portfolio_admin_removal_emails")
|
@patch("registrar.views.portfolios.send_portfolio_admin_removal_emails")
|
||||||
@patch("registrar.views.portfolios.send_portfolio_member_permission_remove_email")
|
@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
|
"""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.
|
not only admin. Because admin, removal emails are sent, but fail to send.
|
||||||
Email to removed member also fails to send."""
|
Email to removed member also fails to send."""
|
||||||
|
@ -1966,7 +1968,6 @@ class TestPortfolioMemberDeleteView(WebTest):
|
||||||
self.assertEqual(called_kwargs["permissions"].user, upp.user)
|
self.assertEqual(called_kwargs["permissions"].user, upp.user)
|
||||||
self.assertEqual(called_kwargs["permissions"].portfolio, upp.portfolio)
|
self.assertEqual(called_kwargs["permissions"].portfolio, upp.portfolio)
|
||||||
|
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
@override_flag("organization_feature", active=True)
|
@override_flag("organization_feature", active=True)
|
||||||
@override_flag("organization_members", active=True)
|
@override_flag("organization_members", active=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue