2021-01-08 13:41:50 +01:00
|
|
|
From e987664551debb9affce8ce5a70593ef0750dcd5 Mon Sep 17 00:00:00 2001
|
2019-01-17 10:18:02 +01:00
|
|
|
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
|
|
|
|
---
|
2021-01-08 13:41:50 +01:00
|
|
|
tests/unit/utils/test_pkg.py | 53 ++++++------------------------------
|
|
|
|
1 file changed, 8 insertions(+), 45 deletions(-)
|
2019-01-17 10:18:02 +01:00
|
|
|
|
|
|
|
diff --git a/tests/unit/utils/test_pkg.py b/tests/unit/utils/test_pkg.py
|
2021-01-08 13:41:50 +01:00
|
|
|
index b4a67b8e57..404b01b12b 100644
|
2019-04-12 11:57:21 +02:00
|
|
|
--- a/tests/unit/utils/test_pkg.py
|
2019-01-17 10:18:02 +01:00
|
|
|
+++ b/tests/unit/utils/test_pkg.py
|
2021-01-08 13:41:50 +01:00
|
|
|
@@ -1,53 +1,16 @@
|
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
|
-
|
|
|
|
-from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
-
|
2019-04-12 11:57:21 +02:00
|
|
|
import salt.utils.pkg
|
2020-04-07 14:14:01 +02:00
|
|
|
from salt.utils.pkg import rpm
|
2021-01-08 13:41:50 +01:00
|
|
|
-from tests.support.mock import MagicMock, patch
|
|
|
|
-from tests.support.unit import TestCase
|
2020-04-07 14:14:01 +02:00
|
|
|
-
|
2021-01-08 13:41:50 +01:00
|
|
|
+from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, Mock, patch
|
|
|
|
+from tests.support.unit import TestCase, skipIf
|
|
|
|
|
2019-04-12 11:57:21 +02:00
|
|
|
-class PkgUtilsTestCase(TestCase):
|
2021-01-08 13:41:50 +01:00
|
|
|
- """
|
2019-04-12 11:57:21 +02:00
|
|
|
- TestCase for salt.utils.pkg module
|
2021-01-08 13:41:50 +01:00
|
|
|
- """
|
|
|
|
-
|
2019-04-12 11:57:21 +02:00
|
|
|
- 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"),
|
2021-01-08 13:41:50 +01:00
|
|
|
- ("", "", ""),
|
2019-04-12 11:57:21 +02:00
|
|
|
- ]
|
|
|
|
-
|
|
|
|
- def test_split_comparison(self):
|
2021-01-08 13:41:50 +01:00
|
|
|
- """
|
2019-04-12 11:57:21 +02:00
|
|
|
- Tests salt.utils.pkg.split_comparison
|
2021-01-08 13:41:50 +01:00
|
|
|
- """
|
2019-04-12 11:57:21 +02:00
|
|
|
- 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)
|
2020-04-07 14:14:01 +02:00
|
|
|
+try:
|
|
|
|
+ import pytest
|
|
|
|
+except ImportError:
|
|
|
|
+ pytest = None
|
|
|
|
|
|
|
|
|
|
|
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2021-01-08 13:41:50 +01:00
|
|
|
+@skipIf(pytest is None, "PyTest is missing")
|
2020-04-07 14:14:01 +02:00
|
|
|
class PkgRPMTestCase(TestCase):
|
2021-01-08 13:41:50 +01:00
|
|
|
"""
|
2020-04-07 14:14:01 +02:00
|
|
|
Test case for pkg.rpm utils
|
2019-01-17 10:18:02 +01:00
|
|
|
--
|
2021-01-08 13:41:50 +01:00
|
|
|
2.29.2
|
2019-01-17 10:18:02 +01:00
|
|
|
|
|
|
|
|