From 0006645d0bd6fc2a699853f9bcc1e7561d44c776 Mon Sep 17 00:00:00 2001 From: Dirk Julich Date: Thu, 18 Jun 2026 14:42:46 +0200 Subject: [PATCH] Fix collection tests: set up managed role definitions The DAB RBAC migration to use RoleUserAssignment subqueries in organization views requires managed role definitions (Organization Member, Organization Admin) to exist in the test database. Add an autouse fixture to the collection test conftest that calls setup_managed_role_definitions() before each test. --- awx_collection/test/awx/conftest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index 4fe89f8b72..fb122ac536 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -20,6 +20,7 @@ from ansible.module_utils.six import raise_from from ansible_base.rbac.models import RoleDefinition, DABPermission from ansible_base.rbac import permission_registry +from awx.main.migrations._dab_rbac import setup_managed_role_definitions from awx.main.tests.conftest import load_all_credentials # noqa: F401; pylint: disable=unused-import from awx.main.tests.functional.conftest import _request from awx.main.tests.functional.conftest import credentialtype_scm, credentialtype_ssh # noqa: F401; pylint: disable=unused-import @@ -92,6 +93,13 @@ def sanitize_dict(din): return str(din) # translation proxies often not string but stringlike +@pytest.fixture(autouse=True) +def _setup_managed_roles(db): + from django.apps import apps as global_apps + + setup_managed_role_definitions(global_apps, None) + + @pytest.fixture(autouse=True) def collection_path_set(monkeypatch): """Monkey patch sys.path, insert the root of the collection folder