Skip to content

Commit cb46ffa

Browse files
Add test for SystemdService.exists
1 parent c535cc7 commit cb46ffa

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/test_modules.py

+19-7
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,37 @@ def test_systeminfo(host, docker_image):
103103
@all_images
104104
def test_ssh_service(host, docker_image):
105105
service_name = ssh_pkg_info[docker_image][2]
106-
ssh = host.service(service_name)
106+
ssh_svc = host.service(service_name)
107107
# wait at max 10 seconds for ssh is running
108108
for _ in range(10):
109-
if ssh.is_running:
109+
if ssh_svc.is_running:
110110
break
111111
time.sleep(1)
112112
else:
113113
raise AssertionError("ssh is not running")
114114

115-
assert ssh.is_enabled
115+
assert ssh_svc.is_enabled
116+
117+
118+
@all_images
119+
def test_systemdservice_exists(host, docker_image):
120+
service_name = ssh_pkg_info[docker_image][2]
121+
for name in [service_name, f"{service_name}.service"]:
122+
ssh_svc = host.service(name)
123+
assert ssh_svc.exists
124+
125+
for name in ["non-existing", "non-existing.service", "non-existing.timer"]:
126+
non_existing_service = host.service(name)
127+
assert not non_existing_service.exists
116128

117129

118130
def test_service_systemd_mask(host):
119-
ssh = host.service("ssh")
120-
assert not ssh.is_masked
131+
ssh_svc = host.service("ssh")
132+
assert not ssh_svc.is_masked
121133
host.run("systemctl mask ssh")
122-
assert ssh.is_masked
134+
assert ssh_svc.is_masked
123135
host.run("systemctl unmask ssh")
124-
assert not ssh.is_masked
136+
assert not ssh_svc.is_masked
125137

126138

127139
def test_salt(host):

0 commit comments

Comments
 (0)