mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 15:06:32 +02:00
performed some cleanup
This commit is contained in:
parent
b86d8bcdc0
commit
2007daadbb
3 changed files with 5 additions and 37 deletions
|
@ -171,8 +171,10 @@ class UserPortfolioPermission(TimeStampedModel):
|
||||||
# The solution to this is to only grab what is only COMMONLY "forbidden".
|
# The solution to this is to only grab what is only COMMONLY "forbidden".
|
||||||
# This will scale if we add more roles in the future.
|
# This will scale if we add more roles in the future.
|
||||||
# This is thes same as applying the `&` operator across all sets for each role.
|
# This is thes same as applying the `&` operator across all sets for each role.
|
||||||
common_forbidden_perms = set.intersection(
|
common_forbidden_perms = (
|
||||||
*[set(cls.FORBIDDEN_PORTFOLIO_ROLE_PERMISSIONS.get(role, [])) for role in roles]
|
set.intersection(*[set(cls.FORBIDDEN_PORTFOLIO_ROLE_PERMISSIONS.get(role, [])) for role in roles])
|
||||||
|
if roles
|
||||||
|
else set()
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if the users current permissions overlap with any forbidden permissions
|
# Check if the users current permissions overlap with any forbidden permissions
|
||||||
|
|
|
@ -675,40 +675,6 @@ class TestPortfolioInvitationAdmin(TestCase):
|
||||||
request, "Could not send email invitation. Portfolio invitation not saved."
|
request, "Could not send email invitation. Portfolio invitation not saved."
|
||||||
)
|
)
|
||||||
|
|
||||||
# @patch("django.contrib.messages.get_messages")
|
|
||||||
# def test_form_rerenders_if_errors_or_warnings(self, mock_get_messages):
|
|
||||||
# """Ensure the form is re-rendered when errors or warnings are present."""
|
|
||||||
# self.client.force_login(self.superuser)
|
|
||||||
|
|
||||||
# # Mock the presence of an error message
|
|
||||||
# mock_message = Mock()
|
|
||||||
# mock_message.level_tag = "error"
|
|
||||||
# mock_message.message = "Simulated error message"
|
|
||||||
# mock_get_messages.return_value = [mock_message]
|
|
||||||
|
|
||||||
# # Create an instance of the admin class
|
|
||||||
# admin_instance = PortfolioInvitationAdmin(PortfolioInvitation, admin_site=AdminSite())
|
|
||||||
|
|
||||||
# # Create a PortfolioInvitation instance
|
|
||||||
# portfolio_invitation = PortfolioInvitation(
|
|
||||||
# email="james.gordon@gotham.gov",
|
|
||||||
# portfolio=self.portfolio,
|
|
||||||
# roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN],
|
|
||||||
# )
|
|
||||||
|
|
||||||
# # Create a request object
|
|
||||||
# request = self.factory.post("/admin/registrar/PortfolioInvitation/add/")
|
|
||||||
# request.user = self.superuser
|
|
||||||
|
|
||||||
# # Trigger response_add
|
|
||||||
# response = admin_instance.response_add(request, portfolio_invitation)
|
|
||||||
|
|
||||||
# # Assert that the response status code is 200 (indicating the form was re-rendered)
|
|
||||||
# self.assertEqual(response.status_code, 200, msg="Expected form to re-render due to errors.")
|
|
||||||
|
|
||||||
# # Assert that the mocked error message is included in the response
|
|
||||||
# self.assertContains(response, "Simulated error message", msg_prefix="Expected error message not found.")
|
|
||||||
|
|
||||||
|
|
||||||
class TestHostAdmin(TestCase):
|
class TestHostAdmin(TestCase):
|
||||||
"""Tests for the HostAdmin class as super user
|
"""Tests for the HostAdmin class as super user
|
||||||
|
|
|
@ -421,7 +421,7 @@ class TestContactForm(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestBasePortfolioMemberForms(TestCase):
|
class TestBasePortfolioMemberForms(TestCase):
|
||||||
"""We test on the child forms instead of BasePortfolioMemberForm becasue the base form
|
"""We test on the child forms instead of BasePortfolioMemberForm because the base form
|
||||||
is a model form with no model bound."""
|
is a model form with no model bound."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue