2021-01-08 13:41:50 +01:00
|
|
|
From e2ff2f339ce7938ecdadf867f285a559bc2431dd Mon Sep 17 00:00:00 2001
|
2020-10-14 17:29:00 +02:00
|
|
|
From: Dominik Gedon <dgedon@suse.de>
|
|
|
|
Date: Tue, 6 Oct 2020 14:00:55 +0200
|
|
|
|
Subject: [PATCH] Fix grains.test_core unit test (#277)
|
|
|
|
|
|
|
|
This reverts 63b94ae and fixes the grains test_core unit test. The
|
|
|
|
changes are aligned with upstream.
|
|
|
|
---
|
2021-01-08 13:41:50 +01:00
|
|
|
tests/unit/grains/test_core.py | 9 ++++-----
|
|
|
|
1 file changed, 4 insertions(+), 5 deletions(-)
|
2020-10-14 17:29:00 +02:00
|
|
|
|
|
|
|
diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py
|
2021-01-08 13:41:50 +01:00
|
|
|
index 918a9155cb..15de4e363e 100644
|
2020-10-14 17:29:00 +02:00
|
|
|
--- a/tests/unit/grains/test_core.py
|
|
|
|
+++ b/tests/unit/grains/test_core.py
|
2021-01-08 13:41:50 +01:00
|
|
|
@@ -60,11 +60,10 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
with salt.utils.files.fopen(
|
|
|
|
os.path.join(OS_RELEASE_DIR, "ubuntu-17.10")
|
|
|
|
) as os_release_file:
|
2020-10-14 17:29:00 +02:00
|
|
|
- os_release_content = os_release_file.readlines()
|
|
|
|
- with patch("salt.utils.files.fopen", mock_open()) as os_release_file:
|
|
|
|
- os_release_file.return_value.__iter__.return_value = os_release_content
|
|
|
|
+ os_release_content = os_release_file.read()
|
|
|
|
+ with patch("salt.utils.files.fopen", mock_open(read_data=os_release_content)):
|
2021-01-08 13:41:50 +01:00
|
|
|
os_release = core._parse_os_release(
|
|
|
|
- ["/etc/os-release", "/usr/lib/os-release"]
|
2020-10-14 17:29:00 +02:00
|
|
|
+ "/etc/os-release", "/usr/lib/os-release"
|
2021-01-08 13:41:50 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
os_release,
|
|
|
|
@@ -174,7 +173,7 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
2020-10-14 17:29:00 +02:00
|
|
|
def test_missing_os_release(self):
|
2021-01-08 13:41:50 +01:00
|
|
|
with patch("salt.utils.files.fopen", mock_open(read_data={})):
|
|
|
|
os_release = core._parse_os_release(
|
|
|
|
- ["/etc/os-release", "/usr/lib/os-release"]
|
2020-10-14 17:29:00 +02:00
|
|
|
+ "/etc/os-release", "/usr/lib/os-release"
|
2021-01-08 13:41:50 +01:00
|
|
|
)
|
2020-10-14 17:29:00 +02:00
|
|
|
self.assertEqual(os_release, {})
|
|
|
|
|
|
|
|
--
|
2021-01-08 13:41:50 +01:00
|
|
|
2.29.2
|
2020-10-14 17:29:00 +02:00
|
|
|
|
|
|
|
|