SHA256
1
0
forked from pool/salt
salt/get-os_arch-also-without-rpm-package-installed.patch

93 lines
2.8 KiB
Diff

From e987664551debb9affce8ce5a70593ef0750dcd5 Mon Sep 17 00:00:00 2001
From: Bo Maryniuk <bo@suse.de>
Date: Wed, 14 Nov 2018 17:36:23 +0100
Subject: [PATCH] Get os_arch also without RPM package installed
backport pkg.rpm test
Add pkg.rpm unit test case
Fix docstring
Add UT for getting OS architecture fallback, when no RPM found (initrd, e.g.)
Add UT for OS architecture detection on fallback, when no CPU arch can be determined
Add UT for OS arch detection when no CPU arch or machine can be determined
Remove unsupported testcase
---
tests/unit/utils/test_pkg.py | 53 ++++++------------------------------
1 file changed, 8 insertions(+), 45 deletions(-)
diff --git a/tests/unit/utils/test_pkg.py b/tests/unit/utils/test_pkg.py
index b4a67b8e57..404b01b12b 100644
--- a/tests/unit/utils/test_pkg.py
+++ b/tests/unit/utils/test_pkg.py
@@ -1,53 +1,16 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import absolute_import, print_function, unicode_literals
-
import salt.utils.pkg
from salt.utils.pkg import rpm
-from tests.support.mock import MagicMock, patch
-from tests.support.unit import TestCase
-
+from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, Mock, patch
+from tests.support.unit import TestCase, skipIf
-class PkgUtilsTestCase(TestCase):
- """
- TestCase for salt.utils.pkg module
- """
-
- test_parameters = [
- ("16.0.0.49153-0+f1", "", "16.0.0.49153-0+f1"),
- ("> 15.0.0", ">", "15.0.0"),
- ("< 15.0.0", "<", "15.0.0"),
- ("<< 15.0.0", "<<", "15.0.0"),
- (">> 15.0.0", ">>", "15.0.0"),
- (">= 15.0.0", ">=", "15.0.0"),
- ("<= 15.0.0", "<=", "15.0.0"),
- ("!= 15.0.0", "!=", "15.0.0"),
- ("<=> 15.0.0", "<=>", "15.0.0"),
- ("<> 15.0.0", "<>", "15.0.0"),
- ("= 15.0.0", "=", "15.0.0"),
- (">15.0.0", ">", "15.0.0"),
- ("<15.0.0", "<", "15.0.0"),
- ("<<15.0.0", "<<", "15.0.0"),
- (">>15.0.0", ">>", "15.0.0"),
- (">=15.0.0", ">=", "15.0.0"),
- ("<=15.0.0", "<=", "15.0.0"),
- ("!=15.0.0", "!=", "15.0.0"),
- ("<=>15.0.0", "<=>", "15.0.0"),
- ("<>15.0.0", "<>", "15.0.0"),
- ("=15.0.0", "=", "15.0.0"),
- ("", "", ""),
- ]
-
- def test_split_comparison(self):
- """
- Tests salt.utils.pkg.split_comparison
- """
- for test_parameter in self.test_parameters:
- oper, verstr = salt.utils.pkg.split_comparison(test_parameter[0])
- self.assertEqual(test_parameter[1], oper)
- self.assertEqual(test_parameter[2], verstr)
+try:
+ import pytest
+except ImportError:
+ pytest = None
+@skipIf(NO_MOCK, NO_MOCK_REASON)
+@skipIf(pytest is None, "PyTest is missing")
class PkgRPMTestCase(TestCase):
"""
Test case for pkg.rpm utils
--
2.29.2