forked from osism/ansible-collection-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.py
38 lines (27 loc) · 1.29 KB
/
package.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pytest
from ..util.util import get_ansible, get_variable
from packaging.version import Version
testinfra_runner, testinfra_hosts = get_ansible()
def check_openstackclient_install_type(host):
if get_variable(host, "openstackclient_install_type") != "package":
pytest.skip("openstackclient_install_type mismatch")
def test_repository_key_installed(host):
check_openstackclient_install_type(host)
debian_version = host.system_info.release
if Version(debian_version) < Version("22.04"):
key = get_variable(host, "openstackclient_debian_repository_key")
assert host.run(f"apt-key list | grep {key}").rc == 0
else:
package = host.package("ubuntu-cloud-keyring")
assert package.is_installed
def test_repository_added(host):
check_openstackclient_install_type(host)
if get_variable(host, "openstackclient_configure_repository"):
repo = get_variable(host, "openstackclient_debian_repository")
assert host.run(f"apt-cache policy | grep {repo.split(' ')[1]}").rc == 0
def test_openstackclient_packages_installed(host):
check_openstackclient_install_type(host)
packages = get_variable(host, "openstackclient_debian_packages")
for package in packages:
pkg = host.package(package)
assert pkg.is_installed