44f6a131de
- Update to 2016.3.4 see https://docs.saltstack.com/en/latest/topics/releases/2016.3.4.html - Removed Patches, applied upstream * 0008-checksum-validation-when-zypper-pkg.download.patch * 0009-unit-tests-for-rpm.checksum-and-zypper.download.patch * 0010-snapper-execution-module.patch * 0011-fix-salt-summary-to-count-not-responding-minions-cor.patch * 0012-Run-salt-api-as-user-salt-bsc-990029.patch * 0013-Deprecate-status.uptime-one-version-later.patch * 0014-Add-ignore_repo_failure-option-to-suppress-zypper-s-.patch * 0015-Remove-zypper-s-raise-exception-if-mod_repo-has-no-a.patch * 0016-Improve-Mock-to-be-flexible-and-able-to-mock-methods.patch * 0017-Check-for-single-quote-before-splitting-on-single-qu.patch * 0018-Unit-tests-fixes-for-2016.3.2.patch * 0019-Fix-snapper_test-for-python26.patch * 0020-Integration-tests-fixes-for-2016.3.2.patch * 0021-Fix-pkg.upgrade-for-zypper.patch * 0022-Setting-up-OS-grains-for-SLES-Expanded-Support-SUSE-.patch * 0023-acl.delfacl-fix-position-of-X-option-to-setfacl.patch * 0024-Change-travis-configuration-file-to-use-salt-toaster.patch * 0025-Adding-dist-upgrade-support-to-zypper-module.patch * 0026-Fix-pkg.latest_version-when-latest-already-installed.patch * 0027-Including-resolver-params-for-Zypper-debug-solver.patch - Added patches * 0008-snapper-execution-module.patch * 0009-fix-salt-summary-to-count-not-responding-minions-cor.patch * 0010-Run-salt-api-as-user-salt-bsc-990029.patch * 0011-Fix-snapper_test-for-python26.patch * 0012-Fix-pkg.upgrade-for-zypper.patch * 0013-Setting-up-OS-grains-for-SLES-Expanded-Support-SUSE-.patch OBS-URL: https://build.opensuse.org/request/show/438684 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=81
114 lines
4.8 KiB
Diff
114 lines
4.8 KiB
Diff
From 65d1dc94577e9bdbaa6c55f7057a78b2fe6010a7 Mon Sep 17 00:00:00 2001
|
|
From: Justin Anderson <janderson@saltstack.com>
|
|
Date: Tue, 23 Aug 2016 15:02:31 -0600
|
|
Subject: [PATCH 11/17] Fix snapper_test for python26
|
|
|
|
* Use assertCountEqual instead of assertItemsEqual for Python 3
|
|
* Skip one Snapper test on 2.6
|
|
There's a slight difference in the diff comparison but we should be
|
|
able to catch true failures here with 2.7.
|
|
---
|
|
tests/unit/modules/snapper_test.py | 41 ++++++++++++++++++++++++++++++--------
|
|
1 file changed, 33 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/tests/unit/modules/snapper_test.py b/tests/unit/modules/snapper_test.py
|
|
index f27b2ba..43f8898 100644
|
|
--- a/tests/unit/modules/snapper_test.py
|
|
+++ b/tests/unit/modules/snapper_test.py
|
|
@@ -6,19 +6,26 @@ Unit tests for the Snapper module
|
|
:codeauthor: Pablo Suárez Hernández <psuarezhernandez@suse.de>
|
|
'''
|
|
|
|
+# Import Python libs
|
|
from __future__ import absolute_import
|
|
+import sys
|
|
|
|
-from salttesting import TestCase
|
|
+# Import Salt Testing libs
|
|
+from salttesting import TestCase, skipIf
|
|
from salttesting.mock import (
|
|
+ NO_MOCK,
|
|
+ NO_MOCK_REASON,
|
|
MagicMock,
|
|
patch,
|
|
mock_open,
|
|
)
|
|
-
|
|
-from salt.exceptions import CommandExecutionError
|
|
from salttesting.helpers import ensure_in_syspath
|
|
+
|
|
ensure_in_syspath('../../')
|
|
|
|
+# Import Salt libs
|
|
+import salt.ext.six as six
|
|
+from salt.exceptions import CommandExecutionError
|
|
from salt.modules import snapper
|
|
|
|
# Globals
|
|
@@ -123,6 +130,13 @@ MODULE_RET = {
|
|
"@@ -0,0 +1 @@\n"
|
|
"+another foobar",
|
|
},
|
|
+ '/tmp/foo26': {
|
|
+ 'comment': 'text file created',
|
|
+ 'diff': "--- /.snapshots/55/snapshot/tmp/foo2 \n"
|
|
+ "+++ /tmp/foo2 \n"
|
|
+ "@@ -1,0 +1,1 @@\n"
|
|
+ "+another foobar",
|
|
+ },
|
|
'/tmp/foo3': {
|
|
'comment': 'binary file changed',
|
|
'old_sha256_digest': 'e61f8b762d83f3b4aeb3689564b0ffbe54fa731a69a1e208dc9440ce0f69d19b',
|
|
@@ -132,6 +146,7 @@ MODULE_RET = {
|
|
}
|
|
|
|
|
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
|
class SnapperTestCase(TestCase):
|
|
def setUp(self):
|
|
self.dbus_mock = MagicMock()
|
|
@@ -220,10 +235,16 @@ class SnapperTestCase(TestCase):
|
|
@patch('salt.modules.snapper.snapper.GetComparison', MagicMock())
|
|
@patch('salt.modules.snapper.snapper.GetFiles', MagicMock(return_value=DBUS_RET['GetFiles']))
|
|
def test_status(self):
|
|
- self.assertItemsEqual(snapper.status(), MODULE_RET['GETFILES'])
|
|
- self.assertItemsEqual(snapper.status(num_pre="42", num_post=43), MODULE_RET['GETFILES'])
|
|
- self.assertItemsEqual(snapper.status(num_pre=42), MODULE_RET['GETFILES'])
|
|
- self.assertItemsEqual(snapper.status(num_post=43), MODULE_RET['GETFILES'])
|
|
+ if six.PY3:
|
|
+ self.assertCountEqual(snapper.status(), MODULE_RET['GETFILES'])
|
|
+ self.assertCountEqual(snapper.status(num_pre="42", num_post=43), MODULE_RET['GETFILES'])
|
|
+ self.assertCountEqual(snapper.status(num_pre=42), MODULE_RET['GETFILES'])
|
|
+ self.assertCountEqual(snapper.status(num_post=43), MODULE_RET['GETFILES'])
|
|
+ else:
|
|
+ self.assertItemsEqual(snapper.status(), MODULE_RET['GETFILES'])
|
|
+ self.assertItemsEqual(snapper.status(num_pre="42", num_post=43), MODULE_RET['GETFILES'])
|
|
+ self.assertItemsEqual(snapper.status(num_pre=42), MODULE_RET['GETFILES'])
|
|
+ self.assertItemsEqual(snapper.status(num_post=43), MODULE_RET['GETFILES'])
|
|
|
|
@patch('salt.modules.snapper.status', MagicMock(return_value=MODULE_RET['GETFILES']))
|
|
def test_changed_files(self):
|
|
@@ -268,7 +289,10 @@ class SnapperTestCase(TestCase):
|
|
@patch('os.path.isfile', MagicMock(side_effect=[False, True]))
|
|
@patch('salt.utils.fopen', mock_open(read_data=FILE_CONTENT["/tmp/foo2"]['post']))
|
|
def test_diff_text_file(self):
|
|
- self.assertEqual(snapper.diff(), {"/tmp/foo2": MODULE_RET['DIFF']['/tmp/foo2']})
|
|
+ if sys.version_info < (2, 7):
|
|
+ self.assertEqual(snapper.diff(), {"/tmp/foo2": MODULE_RET['DIFF']['/tmp/foo26']})
|
|
+ else:
|
|
+ self.assertEqual(snapper.diff(), {"/tmp/foo2": MODULE_RET['DIFF']['/tmp/foo2']})
|
|
|
|
@patch('salt.modules.snapper._get_num_interval', MagicMock(return_value=(55, 0)))
|
|
@patch('salt.modules.snapper.snapper.MountSnapshot', MagicMock(
|
|
@@ -278,6 +302,7 @@ class SnapperTestCase(TestCase):
|
|
@patch('salt.modules.snapper._is_text_file', MagicMock(return_value=True))
|
|
@patch('os.path.isfile', MagicMock(side_effect=[True, True, False, True]))
|
|
@patch('os.path.isdir', MagicMock(return_value=False))
|
|
+ @skipIf(sys.version_info < (2, 7), 'Python 2.7 required to compare diff properly')
|
|
def test_diff_text_files(self):
|
|
fopen_effect = [
|
|
mock_open(read_data=FILE_CONTENT["/tmp/foo"]['pre']).return_value,
|
|
--
|
|
2.10.1
|
|
|