From a5dec8ede9532f0d6cbeda07bbf1868b1e0e9d10 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Fri, 7 Jun 2024 10:08:23 -0400 Subject: [PATCH] Consolidate member test fixtures (#439) --- test_app/tests/authentication/conftest.py | 20 ------------------- .../serializers/test_authenticator_map.py | 4 ++-- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/test_app/tests/authentication/conftest.py b/test_app/tests/authentication/conftest.py index 1b9e60ff9..b06b0ef36 100644 --- a/test_app/tests/authentication/conftest.py +++ b/test_app/tests/authentication/conftest.py @@ -1,7 +1,5 @@ import pytest -from ansible_base.lib.utils.auth import get_organization_model, get_team_model -from ansible_base.rbac import permission_registry from ansible_base.rbac.models import RoleDefinition SYSTEM_ROLE_NAME = 'System role' @@ -14,21 +12,3 @@ def system_role(): return RoleDefinition.objects.create( name=SYSTEM_ROLE_NAME, ) - - -@pytest.fixture -def team_member_role(): - return RoleDefinition.objects.create( - name=TEAM_MEMBER_ROLE_NAME, - content_type=permission_registry.content_type_model.objects.get_for_model(get_team_model()), - managed=True, - ) - - -@pytest.fixture -def organization_member_role(): - return RoleDefinition.objects.create( - name=ORG_MEMBER_ROLE_NAME, - content_type=permission_registry.content_type_model.objects.get_for_model(get_organization_model()), - managed=True, - ) diff --git a/test_app/tests/authentication/serializers/test_authenticator_map.py b/test_app/tests/authentication/serializers/test_authenticator_map.py index 895480298..defdd9b56 100644 --- a/test_app/tests/authentication/serializers/test_authenticator_map.py +++ b/test_app/tests/authentication/serializers/test_authenticator_map.py @@ -81,7 +81,7 @@ def test_validate_role_system_role(self, serializer, system_role): serializer.validate(dict(name="authentication_map_5", map_type="organization", role=SYSTEM_ROLE_NAME, organization='test_org')) assert str(e.value) == "{'role': ErrorDetail(string='For an organization map type you must specify an organization based role', code='invalid')}" - def test_validate_role_team_role(self, serializer, team_member_role): + def test_validate_role_team_role(self, serializer, member_rd): with pytest.raises(ValidationError) as e: serializer.validate(dict(name="authentication_map_1", map_type="role", role=TEAM_MEMBER_ROLE_NAME)) assert set(e.value.detail.keys()) == {'organization', 'team'} @@ -106,7 +106,7 @@ def test_validate_role_team_role(self, serializer, team_member_role): ) assert str(e.value) == "{'role': ErrorDetail(string='For an organization map type you must specify an organization based role', code='invalid')}" - def test_validate_role_organization_role(self, serializer, organization_member_role): + def test_validate_role_organization_role(self, serializer, org_member_rd): with pytest.raises(ValidationError) as e: serializer.validate(dict(name="authentication_map_1", map_type="role", role=ORG_MEMBER_ROLE_NAME)) assert str(e.value) == "{'organization': ErrorDetail(string='You must specify an organization with the selected role', code='invalid')}"