diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index cb41b3a4..4150c602 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -50,7 +50,7 @@ jobs: matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} env: FORCE_COLOR: 1 - PYTEST_REQPASS: 108 + PYTEST_REQPASS: 109 steps: - uses: actions/checkout@v4 with: diff --git a/test/test_runtime.py b/test/test_runtime.py index 605dc028..4e086cdf 100644 --- a/test/test_runtime.py +++ b/test/test_runtime.py @@ -742,6 +742,44 @@ def test_install_collection_from_disk( runtime.clean() +@pytest.mark.parametrize( + ("path", "expected_plugins"), + ( + pytest.param( + "test/collections/acme.goodies", + [ + "ansible.posix.patch", # from tests/requirements.yml + "ansible.utils.validate", # from galaxy.yml + "community.crypto.acme_account", # from galaxy.yml as a git dependency + ], + id="modules", + ), + ), +) +def test_load_plugins( + path: str, + expected_plugins: list[str], +) -> None: + """Tests ability to load plugin from a collection installed by requirement.""" + with cwd(Path(path)): + from ansible.plugins.loader import module_loader + from ansible_compat.prerun import get_cache_dir + rmtree(get_cache_dir(Path.cwd()), ignore_errors=True) + runtime = Runtime(isolated=True, require_module=True) + runtime.prepare_environment(install_local=True) + for plugin_name in expected_plugins: + loaded_module = module_loader.find_plugin_with_context( + plugin_name, + ignore_deprecated=True, + check_aliases=True, + ) + assert ( + loaded_module.resolved_fqcn is not None + ), f"Unable to load module {plugin_name}" + + runtime.clean() + + def test_install_collection_from_disk_fail() -> None: """Tests that we fail to install a broken collection.""" with cwd(Path("test/collections/acme.broken")):