mirror of
https://github.com/ansible/awx.git
synced 2026-06-20 14:17:42 -02:30
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user