performed some cleanup

This commit is contained in:
David Kennedy 2024-12-31 08:16:28 -05:00
parent b86d8bcdc0
commit 2007daadbb
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 5 additions and 37 deletions

View file

@ -171,8 +171,10 @@ class UserPortfolioPermission(TimeStampedModel):
# 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 is thes same as applying the `&` operator across all sets for each role.
common_forbidden_perms = set.intersection(
*[set(cls.FORBIDDEN_PORTFOLIO_ROLE_PERMISSIONS.get(role, [])) for role in roles]
common_forbidden_perms = (
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

View file

@ -675,40 +675,6 @@ class TestPortfolioInvitationAdmin(TestCase):
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):
"""Tests for the HostAdmin class as super user

View file

@ -421,7 +421,7 @@ class TestContactForm(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."""
def setUp(self):