Skip to content

Commit e7a9982

Browse files
Add test for SystemdService.exists
1 parent 77234ec commit e7a9982

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/test_modules.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,37 @@ def test_systeminfo(host, docker_image):
116116
@all_images
117117
def test_ssh_service(host, docker_image):
118118
service_name = ssh_pkg_info[docker_image][2]
119-
ssh = host.service(service_name)
119+
ssh_svc = host.service(service_name)
120120
# wait at max 10 seconds for ssh is running
121121
for _ in range(10):
122-
if ssh.is_running:
122+
if ssh_svc.is_running:
123123
break
124124
time.sleep(1)
125125
else:
126126
raise AssertionError("ssh is not running")
127127

128-
assert ssh.is_enabled
128+
assert ssh_svc.is_enabled
129+
130+
131+
@all_images
132+
def test_systemdservice_exists(host, docker_image):
133+
service_name = ssh_pkg_info[docker_image][2]
134+
for name in [service_name, f"{service_name}.service"]:
135+
ssh_svc = host.service(name)
136+
assert ssh_svc.exists
137+
138+
for name in ["non-existing", "non-existing.service", "non-existing.timer"]:
139+
non_existing_service = host.service(name)
140+
assert not non_existing_service.exists
129141

130142

131143
def test_service_systemd_mask(host):
132-
ssh = host.service("ssh")
133-
assert not ssh.is_masked
144+
ssh_svc = host.service("ssh")
145+
assert not ssh_svc.is_masked
134146
host.run("systemctl mask ssh")
135-
assert ssh.is_masked
147+
assert ssh_svc.is_masked
136148
host.run("systemctl unmask ssh")
137-
assert not ssh.is_masked
149+
assert not ssh_svc.is_masked
138150

139151

140152
def test_salt(host):

0 commit comments

Comments
 (0)