Skip to content

Commit aa561ca

Browse files
Enable testing without galaxy (#206)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b2fb9d1 commit aa561ca

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

test/test_runtime.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ def test_require_collection_wrong_version(runtime: Runtime) -> None:
371371
"ansible-galaxy",
372372
"collection",
373373
"install",
374-
"containers.podman",
374+
"examples/reqs_v2/community-molecule-0.1.0.tar.gz",
375375
"-p",
376376
"~/.ansible/collections",
377377
]
378378
)
379379
with pytest.raises(InvalidPrerequisiteError) as pytest_wrapped_e:
380-
runtime.require_collection("containers.podman", "9999.9.9")
380+
runtime.require_collection("community.molecule", "9999.9.9")
381381
assert pytest_wrapped_e.type == InvalidPrerequisiteError
382382
assert pytest_wrapped_e.value.code == INVALID_PREREQUISITES_RC
383383

@@ -435,22 +435,24 @@ def test_require_collection_missing(
435435

436436
def test_install_collection(runtime: Runtime) -> None:
437437
"""Check that valid collection installs do not fail."""
438-
runtime.install_collection("containers.podman:>=1.0")
438+
runtime.install_collection("examples/reqs_v2/community-molecule-0.1.0.tar.gz")
439439

440440

441441
def test_install_collection_dest(runtime: Runtime, tmp_path: pathlib.Path) -> None:
442442
"""Check that valid collection to custom destination passes."""
443-
runtime.install_collection("containers.podman:>=1.0", destination=tmp_path)
443+
runtime.install_collection(
444+
"examples/reqs_v2/community-molecule-0.1.0.tar.gz", destination=tmp_path
445+
)
444446
expected_file = (
445-
tmp_path / "ansible_collections" / "containers" / "podman" / "MANIFEST.json"
447+
tmp_path / "ansible_collections" / "community" / "molecule" / "MANIFEST.json"
446448
)
447449
assert expected_file.is_file()
448450

449451

450452
def test_install_collection_fail(runtime: Runtime) -> None:
451453
"""Check that invalid collection install fails."""
452454
with pytest.raises(AnsibleCompatError) as pytest_wrapped_e:
453-
runtime.install_collection("containers.podman:>=9999.0")
455+
runtime.install_collection("community.molecule:>=9999.0")
454456
assert pytest_wrapped_e.type == InvalidPrerequisiteError
455457
assert pytest_wrapped_e.value.code == INVALID_PREREQUISITES_RC
456458

@@ -560,15 +562,15 @@ def test_upgrade_collection(runtime_tmp: Runtime) -> None:
560562
runtime_tmp.prepare_environment()
561563

562564
# we install specific oudated version of a collection
563-
runtime_tmp.install_collection("containers.podman:==1.6.0")
565+
runtime_tmp.install_collection("examples/reqs_v2/community-molecule-0.1.0.tar.gz")
564566
with pytest.raises(
565567
InvalidPrerequisiteError,
566-
match="Found containers.podman collection 1.6.0 but 1.6.1 or newer is required.",
568+
match="Found community.molecule collection 0.1.0 but 9.9.9 or newer is required.",
567569
):
568570
# we check that when install=False, we raise error
569-
runtime_tmp.require_collection("containers.podman", "1.6.1", install=False)
570-
# now we really perform the upgrade
571-
runtime_tmp.require_collection("containers.podman", "1.6.1")
571+
runtime_tmp.require_collection("community.molecule", "9.9.9", install=False)
572+
# this should not fail, as we have this version
573+
runtime_tmp.require_collection("community.molecule", "0.1.0")
572574

573575

574576
def test_require_collection_no_cache_dir() -> None:

test/test_runtime_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_runtime_example() -> None:
1717
runtime.prepare_environment(install_local=True) # will retry 3 times if needed
1818

1919
# Install a new collection (will retry 3 times if needed)
20-
runtime.install_collection("containers.podman")
20+
runtime.install_collection("examples/reqs_v2/community-molecule-0.1.0.tar.gz")
2121

2222
# Execute a command
2323
result = runtime.exec(["ansible-doc", "--list"])

0 commit comments

Comments
 (0)