2020-04-07 14:14:01 +02:00
|
|
|
From 6bb7b6c4a530abb7e831449545a35ee5ede49dcb 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
|
|
|
|
|
|
|
|
---
|
|
|
|
tests/unit/grains/test_core.py | 11 +++++------
|
|
|
|
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py
|
2020-04-07 14:14:01 +02:00
|
|
|
index b31f5dcddd..c40595eb3f 100644
|
2019-01-17 10:18:02 +01:00
|
|
|
--- a/tests/unit/grains/test_core.py
|
|
|
|
+++ b/tests/unit/grains/test_core.py
|
2019-11-28 16:41:55 +01:00
|
|
|
@@ -68,11 +68,10 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
2019-01-17 10:18:02 +01:00
|
|
|
def test_parse_etc_os_release(self, path_isfile_mock):
|
|
|
|
path_isfile_mock.side_effect = lambda x: x == "/usr/lib/os-release"
|
|
|
|
with salt.utils.files.fopen(os.path.join(OS_RELEASE_DIR, "ubuntu-17.10")) as os_release_file:
|
|
|
|
- os_release_content = os_release_file.read()
|
|
|
|
- with patch("salt.utils.files.fopen", mock_open(read_data=os_release_content)):
|
|
|
|
- os_release = core._parse_os_release(
|
|
|
|
- '/etc/os-release',
|
|
|
|
- '/usr/lib/os-release')
|
|
|
|
+ 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 = core._parse_os_release(["/etc/os-release", "/usr/lib/os-release"])
|
|
|
|
self.assertEqual(os_release, {
|
|
|
|
"NAME": "Ubuntu",
|
|
|
|
"VERSION": "17.10 (Artful Aardvark)",
|
2019-11-28 16:41:55 +01:00
|
|
|
@@ -134,7 +133,7 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
2019-01-17 10:18:02 +01:00
|
|
|
|
|
|
|
def test_missing_os_release(self):
|
|
|
|
with patch('salt.utils.files.fopen', mock_open(read_data={})):
|
|
|
|
- os_release = core._parse_os_release('/etc/os-release', '/usr/lib/os-release')
|
|
|
|
+ os_release = core._parse_os_release(['/etc/os-release', '/usr/lib/os-release'])
|
|
|
|
self.assertEqual(os_release, {})
|
|
|
|
|
2019-11-28 16:41:55 +01:00
|
|
|
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
|
2019-01-17 10:18:02 +01:00
|
|
|
--
|
2019-11-28 16:41:55 +01:00
|
|
|
2.16.4
|
2019-01-17 10:18:02 +01:00
|
|
|
|
|
|
|
|