diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 00:24:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 00:24:37 +0000 |
commit | 1022b2cebe73db426241c2f420d4ee9f6f3c1bed (patch) | |
tree | a5c38ccfaa66e8a52767dec01d3598b67a7422a8 /test/test_runtime_example.py | |
parent | Initial commit. (diff) | |
download | python-ansible-compat-1022b2cebe73db426241c2f420d4ee9f6f3c1bed.tar.xz python-ansible-compat-1022b2cebe73db426241c2f420d4ee9f6f3c1bed.zip |
Adding upstream version 4.1.11.upstream/4.1.11
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test_runtime_example.py')
-rw-r--r-- | test/test_runtime_example.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test_runtime_example.py b/test/test_runtime_example.py new file mode 100644 index 0000000..e500e59 --- /dev/null +++ b/test/test_runtime_example.py @@ -0,0 +1,24 @@ +"""Sample use of Runtime class.""" +from ansible_compat.runtime import Runtime + + +def test_runtime_example() -> None: + """Test basic functionality of Runtime class.""" + # instantiate the runtime using isolated mode, so installing new + # roles/collections do not pollute the default setup. + runtime = Runtime(isolated=True, max_retries=3) + + # Print Ansible core version + _ = runtime.version # 2.9.10 (Version object) + # Get configuration info from runtime + _ = runtime.config.collections_path + + # Detect if current project is a collection and install its requirements + runtime.prepare_environment(install_local=True) # will retry 3 times if needed + + # Install a new collection (will retry 3 times if needed) + runtime.install_collection("examples/reqs_v2/community-molecule-0.1.0.tar.gz") + + # Execute a command + result = runtime.run(["ansible-doc", "--list"]) + assert result.returncode == 0 |