5af0dfb7fe
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=189
81 lines
4.1 KiB
Diff
81 lines
4.1 KiB
Diff
From 74d8f5f2d896e5e8bbf7d3fb614ae32f2cf489a5 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
|
<psuarezhernandez@suse.com>
|
|
Date: Wed, 11 Aug 2021 11:44:54 +0100
|
|
Subject: [PATCH] Fix failing unit tests for systemd
|
|
|
|
---
|
|
tests/unit/modules/test_systemd_service.py | 24 ++++++++++++++++------
|
|
1 file changed, 18 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/tests/unit/modules/test_systemd_service.py b/tests/unit/modules/test_systemd_service.py
|
|
index bbd89bb3d0..51be130d29 100644
|
|
--- a/tests/unit/modules/test_systemd_service.py
|
|
+++ b/tests/unit/modules/test_systemd_service.py
|
|
@@ -165,21 +165,27 @@ class SystemdTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
# systemd < 231
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 230}):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertTrue(systemd.available("sshd.service"))
|
|
self.assertFalse(systemd.available("foo.service"))
|
|
|
|
# systemd >= 231
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 231}):
|
|
with patch.dict(_SYSTEMCTL_STATUS, _SYSTEMCTL_STATUS_GTE_231):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertTrue(systemd.available("sshd.service"))
|
|
self.assertFalse(systemd.available("bar.service"))
|
|
|
|
# systemd < 231 with retcode/output changes backported (e.g. RHEL 7.3)
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 219}):
|
|
with patch.dict(_SYSTEMCTL_STATUS, _SYSTEMCTL_STATUS_GTE_231):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertTrue(systemd.available("sshd.service"))
|
|
self.assertFalse(systemd.available("bar.service"))
|
|
|
|
@@ -191,21 +197,27 @@ class SystemdTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
# systemd < 231
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 230}):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertFalse(systemd.missing("sshd.service"))
|
|
self.assertTrue(systemd.missing("foo.service"))
|
|
|
|
# systemd >= 231
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 231}):
|
|
with patch.dict(_SYSTEMCTL_STATUS, _SYSTEMCTL_STATUS_GTE_231):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertFalse(systemd.missing("sshd.service"))
|
|
self.assertTrue(systemd.missing("bar.service"))
|
|
|
|
# systemd < 231 with retcode/output changes backported (e.g. RHEL 7.3)
|
|
with patch.dict(systemd.__context__, {"salt.utils.systemd.version": 219}):
|
|
with patch.dict(_SYSTEMCTL_STATUS, _SYSTEMCTL_STATUS_GTE_231):
|
|
- with patch.object(systemd, "_systemctl_status", mock):
|
|
+ with patch.object(systemd, "_systemctl_status", mock), patch.object(
|
|
+ systemd, "offline", MagicMock(return_value=False)
|
|
+ ):
|
|
self.assertFalse(systemd.missing("sshd.service"))
|
|
self.assertTrue(systemd.missing("bar.service"))
|
|
|
|
--
|
|
2.32.0
|
|
|
|
|