diff --git a/src/registrar/models/user_portfolio_permission.py b/src/registrar/models/user_portfolio_permission.py index 25abb6748..03a01b80d 100644 --- a/src/registrar/models/user_portfolio_permission.py +++ b/src/registrar/models/user_portfolio_permission.py @@ -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 diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 02f44c5cf..dceb3a79e 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -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 diff --git a/src/registrar/tests/test_forms.py b/src/registrar/tests/test_forms.py index 47b0f3158..a2960deac 100644 --- a/src/registrar/tests/test_forms.py +++ b/src/registrar/tests/test_forms.py @@ -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):