|
31 | 31 | ]
|
32 | 32 | )
|
33 | 33 |
|
| 34 | +# content: ssh version, release shortcut, |
| 35 | +ssh_pkg_info = { |
| 36 | + "rockylinux9": ("8.", ".el9"), |
| 37 | + "debian_bookworm": ("1:9.2", None), |
| 38 | +} |
| 39 | + |
| 40 | +# content: distribution, codename, architecture, release_regex |
| 41 | +docker_image_info = { |
| 42 | + "rockylinux9": ("rocky", None, "x86_64", r"^9.\d+$"), |
| 43 | + "debian_bookworm": ("debian", "bookworm", "amd64", r"^12"), |
| 44 | +} |
| 45 | + |
34 | 46 |
|
35 | 47 | @all_images
|
36 | 48 | def test_package(host, docker_image):
|
37 | 49 | assert not host.package("zsh").is_installed
|
38 | 50 | ssh = host.package("openssh-server")
|
39 |
| - version = { |
40 |
| - "rockylinux9": "8.", |
41 |
| - "debian_bookworm": "1:9.2", |
42 |
| - }[docker_image] |
| 51 | + ssh_version, sshd_release = ssh_pkg_info[docker_image] |
43 | 52 | assert ssh.is_installed
|
44 |
| - assert ssh.version.startswith(version) |
45 |
| - release = { |
46 |
| - "rockylinux9": ".el9", |
47 |
| - "debian_bookworm": None, |
48 |
| - }[docker_image] |
49 |
| - if release is None: |
| 53 | + assert ssh.version.startswith(ssh_version) |
| 54 | + if sshd_release is None: |
50 | 55 | with pytest.raises(NotImplementedError):
|
51 | 56 | ssh.release
|
52 | 57 | else:
|
53 |
| - assert release in ssh.release |
| 58 | + assert sshd_release in ssh.release |
54 | 59 |
|
55 | 60 |
|
56 | 61 | def test_held_package(host):
|
@@ -89,14 +94,10 @@ def test_uninstalled_package_version(host):
|
89 | 94 | def test_systeminfo(host, docker_image):
|
90 | 95 | assert host.system_info.type == "linux"
|
91 | 96 |
|
92 |
| - release, distribution, codename, arch = { |
93 |
| - "rockylinux9": (r"^9.\d+$", "rocky", None, "x86_64"), |
94 |
| - "debian_bookworm": (r"^12", "debian", "bookworm", "x86_64"), |
95 |
| - }[docker_image] |
96 |
| - |
| 97 | + distribution, codename, unused_arch, release_regex = docker_image_info[docker_image] |
97 | 98 | assert host.system_info.distribution == distribution
|
98 | 99 | assert host.system_info.codename == codename
|
99 |
| - assert re.match(release, host.system_info.release) |
| 100 | + assert re.match(release_regex, host.system_info.release) |
100 | 101 |
|
101 | 102 |
|
102 | 103 | @all_images
|
@@ -318,7 +319,7 @@ def test_file(host):
|
318 | 319 |
|
319 | 320 |
|
320 | 321 | def test_ansible_unavailable(host):
|
321 |
| - expected = "Ansible module is only available with " "ansible connection backend" |
| 322 | + expected = "Ansible module is only available with ansible connection backend" |
322 | 323 | with pytest.raises(RuntimeError) as excinfo:
|
323 | 324 | host.ansible("setup")
|
324 | 325 | assert expected in str(excinfo.value)
|
|
0 commit comments