diff --git a/conftest.py b/conftest.py index 93731df..2f22153 100644 --- a/conftest.py +++ b/conftest.py @@ -8,7 +8,7 @@ from molecule import config, logger, util from molecule.scenario import ephemeral_directory -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -19,7 +19,7 @@ def run_command(cmd, env=os.environ, log=True): if log: cmd = _rebake_command(cmd, env) cmd = cmd.bake(_truncate_exc=False) - return App.run_command(cmd, env=env) + return get_app(Path()).run_command(cmd, env=env) def _rebake_command(cmd, env, out=LOG.info, err=LOG.error): diff --git a/pyproject.toml b/pyproject.toml index 18d1c2d..c651f76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ classifiers = [ keywords = ["ansible", "testing", "molecule", "plugin"] dependencies = [ # molecule plugins are not allowed to mention Ansible as a direct dependency - "molecule >= 6.0.0a1", + "molecule >= 25.1.0", ] [project.urls] diff --git a/src/molecule_plugins/podman/driver.py b/src/molecule_plugins/podman/driver.py index 03c6874..dae95bc 100644 --- a/src/molecule_plugins/podman/driver.py +++ b/src/molecule_plugins/podman/driver.py @@ -31,7 +31,7 @@ from molecule.api import Driver, MoleculeRuntimeWarning from molecule.constants import RC_SETUP_ERROR from molecule.util import sysexit_with_message -from molecule.app import App +from molecule.app import get_app log = logger.get_logger(__name__) @@ -247,4 +247,4 @@ def required_collections(self) -> dict[str, str]: def reset(self): # keep `--filter` in sync with playbooks/create.yml - App.run_command(["podman", "rm", "--force", "--filter=label=owner=molecule"]) + get_app(Path()).run_command(["podman", "rm", "--force", "--filter=label=owner=molecule"]) diff --git a/test/azure/functional/test_azure.py b/test/azure/functional/test_azure.py index ddf7c66..5c4cc25 100644 --- a/test/azure/functional/test_azure.py +++ b/test/azure/functional/test_azure.py @@ -25,7 +25,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -33,7 +33,7 @@ def test_azure_command_init_scenario(temp_dir): role_directory = os.path.join(temp_dir.strpath, "test_init") cmd = ["ansible-galaxy", "role", "init", "test_init"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 with change_dir_to(role_directory): @@ -47,7 +47,7 @@ def test_azure_command_init_scenario(temp_dir): "-a", 'path=meta/main.yml line=" namespace: foo" insertafter=" author: your name"', ] - App.run_command(cmd_meta, check=True) + get_app(Path()).run_command(cmd_meta, check=True) # we need to inject namespace info into tests/test.yml cmd_tests = [ @@ -59,7 +59,7 @@ def test_azure_command_init_scenario(temp_dir): "-a", 'path=tests/test.yml line=" - foo.test_init" regex="^(.*) - test_init"', ] - App.run_command(cmd_tests, check=True) + get_app(Path()).run_command(cmd_tests, check=True) molecule_directory = pytest.helpers.molecule_directory() scenario_directory = os.path.join(molecule_directory, "test_scenario") @@ -71,7 +71,7 @@ def test_azure_command_init_scenario(temp_dir): "--driver-name", "azure", ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -82,5 +82,5 @@ def test_azure_command_init_scenario(temp_dir): # temporary trick to pass on CI/CD if "AZURE_SECRET" in os.environ: cmd = ["molecule", "test", "-s", "test-scenario"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 diff --git a/test/containers/functional/test_containers.py b/test/containers/functional/test_containers.py index e012fa0..d230bf5 100644 --- a/test/containers/functional/test_containers.py +++ b/test/containers/functional/test_containers.py @@ -23,7 +23,7 @@ from conftest import change_dir_to, molecule_directory from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -40,7 +40,7 @@ def test_containers_command_init_scenario(temp_dir): "--driver-name", "containers", ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -49,5 +49,5 @@ def test_containers_command_init_scenario(temp_dir): # is shorter but comprehensive enough to test the most important # functionality: destroy, dependency, create, prepare, converge cmd = ["molecule", "check", "-s", "default"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 diff --git a/test/docker/test_func.py b/test/docker/test_func.py index 6d1e944..171163c 100644 --- a/test/docker/test_func.py +++ b/test/docker/test_func.py @@ -9,7 +9,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -40,21 +40,21 @@ def test_command_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) -> "--driver-name", DRIVER, ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() # run molecule reset as this may clean some leftovers from other # test runs and also ensure that reset works. - result = App.run_command(["molecule", "reset"]) # default scenario + result = get_app(Path()).run_command(["molecule", "reset"]) # default scenario assert result.returncode == 0 - result = App.run_command(["molecule", "reset", "-s", scenario_name]) + result = get_app(Path()).run_command(["molecule", "reset", "-s", scenario_name]) assert result.returncode == 0 cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -63,7 +63,7 @@ def test_command_static_scenario() -> None: """Validate that the scenario we included with code still works.""" cmd = ["molecule", "test"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -72,7 +72,7 @@ def test_dockerfile_with_context() -> None: """Verify that Dockerfile.j2 with context works.""" with change_dir_to("test/docker/scenarios/with-context"): cmd = ["molecule", "--debug", "test"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -82,5 +82,5 @@ def test_env_substitution() -> None: os.environ["MOLECULE_ROLE_IMAGE"] = "debian:bullseye" with change_dir_to("test/docker/scenarios/env-substitution"): cmd = ["molecule", "--debug", "test"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 diff --git a/test/ec2/functional/test_ec2.py b/test/ec2/functional/test_ec2.py index 6df4eea..fd65679 100644 --- a/test/ec2/functional/test_ec2.py +++ b/test/ec2/functional/test_ec2.py @@ -25,7 +25,7 @@ from conftest import change_dir_to, metadata_lint_update from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -34,7 +34,7 @@ def test_ec2_command_init_scenario(temp_dir): role_directory = os.path.join(temp_dir.strpath, "test-init") cmd = ["molecule", "init", "role", "test-init"] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 metadata_lint_update(role_directory) with change_dir_to(role_directory): @@ -48,11 +48,11 @@ def test_ec2_command_init_scenario(temp_dir): "--role_name=test-init", "--driver-name=ec2", ] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 assert os.path.isdir(scenario_directory) os.unlink(os.path.join(scenario_directory, "create.yml")) os.unlink(os.path.join(scenario_directory, "destroy.yml")) cmd = ["molecule", "test", "-s", "test-scenario"] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 diff --git a/test/gce/functional/test_func.py b/test/gce/functional/test_func.py index e220b9f..b0ebe5f 100644 --- a/test/gce/functional/test_func.py +++ b/test/gce/functional/test_func.py @@ -25,7 +25,7 @@ from conftest import change_dir_to, metadata_lint_update from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) driver_name = __name__.split(".")[0].split("_")[-1] @@ -36,7 +36,7 @@ def test_gce_command_init_scenario(temp_dir): """Test init scenario with driver.""" role_directory = os.path.join(temp_dir.strpath, "test-init") cmd = ["molecule", "init", "role", "test-init"] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 metadata_lint_update(role_directory) with change_dir_to(role_directory): @@ -52,11 +52,11 @@ def test_gce_command_init_scenario(temp_dir): "--driver-name", driver_name, ] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 assert os.path.isdir(scenario_directory) os.unlink(os.path.join(scenario_directory, "create.yml")) os.unlink(os.path.join(scenario_directory, "destroy.yml")) cmd = ["molecule", "test", "-s", "test-scenario"] - assert App.run_command(cmd).returncode == 0 + assert get_app(Path()).run_command(cmd).returncode == 0 diff --git a/test/openstack/test_func.py b/test/openstack/test_func.py index 155e7ab..340b03b 100644 --- a/test/openstack/test_func.py +++ b/test/openstack/test_func.py @@ -10,7 +10,7 @@ import openstack from conftest import change_dir_to from molecule import logger -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -53,7 +53,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) - "--driver-name", DRIVER, ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() @@ -71,7 +71,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) - shutil.copyfile(testconf, confpath) cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -86,5 +86,5 @@ def test_specific_scenarios(temp_dir, scenario) -> None: with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", scenario] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 diff --git a/test/podman/test_func.py b/test/podman/test_func.py index 87099f6..47f1889 100644 --- a/test/podman/test_func.py +++ b/test/podman/test_func.py @@ -6,7 +6,7 @@ from conftest import change_dir_to from molecule import logger -from molecule.app import App +from molecule.app import get_app from molecule_plugins.podman import __file__ as module_file LOG = logger.get_logger(__name__) @@ -35,27 +35,27 @@ def test_podman_command_init_scenario(tmp_path: pathlib.Path): "--driver-name", "podman", ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert scenario_directory.exists() # run molecule reset as this may clean some leftovers from other # test runs and also ensure that reset works. - result = App.run_command(["molecule", "reset"]) # default sceanario + result = get_app(Path()).run_command(["molecule", "reset"]) # default sceanario assert result.returncode == 0 - result = App.run_command(["molecule", "reset", "-s", scenario_name]) + result = get_app(Path()).run_command(["molecule", "reset", "-s", scenario_name]) assert result.returncode == 0 cmd = ["molecule", "--debug", "test", "-s", scenario_name] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 def test_sample() -> None: """Runs the sample scenario present at the repository root.""" - result = App.run_command(["molecule", "test", "-s", "test-podman"]) # default sceanario + result = get_app(Path()).run_command(["molecule", "test", "-s", "test-podman"]) # default sceanario assert result.returncode == 0 diff --git a/test/vagrant-plugin/functional/test_func.py b/test/vagrant-plugin/functional/test_func.py index 403901a..a3c9c88 100644 --- a/test/vagrant-plugin/functional/test_func.py +++ b/test/vagrant-plugin/functional/test_func.py @@ -29,7 +29,7 @@ from conftest import change_dir_to from molecule import logger, util from molecule.scenario import ephemeral_directory -from molecule.app import App +from molecule.app import get_app LOG = logger.get_logger(__name__) @@ -59,7 +59,7 @@ def test_vagrant_command_init_scenario(temp_dir): "--driver-name", "vagrant", ] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 assert os.path.isdir(scenario_directory) @@ -77,7 +77,7 @@ def test_vagrant_command_init_scenario(temp_dir): conf["driver"]["provider"] = {"name": "libvirt"} util.write_file(confpath, util.safe_dump(conf)) cmd = ["molecule", "--debug", "test", "-s", "test-scenario"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -94,7 +94,7 @@ def test_invalid_settings(temp_dir): with change_dir_to(scenario_directory): cmd = ["molecule", "create", "--scenario-name", "invalid"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 2 assert "Failed to validate generated Vagrantfile" in result.stdout @@ -126,7 +126,7 @@ def test_vagrant_root(temp_dir, scenario): with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", scenario] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 @@ -143,7 +143,7 @@ def test_multi_node(temp_dir): with change_dir_to(scenario_directory): cmd = ["molecule", "test", "--scenario-name", "multi-node"] - result = App.run_command(cmd) + result = get_app(Path()).run_command(cmd) assert result.returncode == 0 molecule_eph_directory = ephemeral_directory()