2021-01-08 13:41:50 +01:00
|
|
|
From 192bac1ae2f20b098384264c8802034a340cd124 Mon Sep 17 00:00:00 2001
|
2019-01-17 10:18:02 +01:00
|
|
|
From: Bo Maryniuk <bo@suse.de>
|
|
|
|
Date: Thu, 11 Oct 2018 16:20:40 +0200
|
|
|
|
Subject: [PATCH] Fix unit test for grains core
|
|
|
|
|
|
|
|
---
|
2021-01-08 13:41:50 +01:00
|
|
|
tests/unit/grains/test_core.py | 9 +++++----
|
|
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
2019-01-17 10:18:02 +01: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 34aaa4f5bc..7dbf34deac 100644
|
2019-01-17 10:18:02 +01:00
|
|
|
--- a/tests/unit/grains/test_core.py
|
|
|
|
+++ b/tests/unit/grains/test_core.py
|
2021-01-08 13:41:50 +01:00
|
|
|
@@ -59,10 +59,11 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
with salt.utils.files.fopen(
|
|
|
|
os.path.join(OS_RELEASE_DIR, "ubuntu-17.10")
|
|
|
|
) as os_release_file:
|
2019-01-17 10:18:02 +01:00
|
|
|
- os_release_content = os_release_file.read()
|
|
|
|
- with patch("salt.utils.files.fopen", mock_open(read_data=os_release_content)):
|
|
|
|
+ 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
|
2021-01-08 13:41:50 +01:00
|
|
|
os_release = core._parse_os_release(
|
|
|
|
- "/etc/os-release", "/usr/lib/os-release"
|
|
|
|
+ ["/etc/os-release", "/usr/lib/os-release"]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
os_release,
|
|
|
|
@@ -172,7 +173,7 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
2019-01-17 10:18:02 +01: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"
|
|
|
|
+ ["/etc/os-release", "/usr/lib/os-release"]
|
|
|
|
)
|
2019-01-17 10:18:02 +01:00
|
|
|
self.assertEqual(os_release, {})
|
|
|
|
|
|
|
|
--
|
2021-01-08 13:41:50 +01:00
|
|
|
2.29.2
|
2019-01-17 10:18:02 +01:00
|
|
|
|
|
|
|
|