Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.3314
0051-unit-tests-for-rpm.checksum-and-zypper.dow...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0051-unit-tests-for-rpm.checksum-and-zypper.download.patch of Package salt.3314
From 7ae7279f657aad41c8d0ad9e2df54704f37b90bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= <psuarezhernandez@suse.com> Date: Wed, 25 May 2016 17:08:16 +0100 Subject: [PATCH 51/52] unit tests for rpm.checksum() and zypper.download() lint issue fixed --- tests/unit/modules/rpm_test.py | 16 ++++++++++++++++ tests/unit/modules/zypp/zypper-download.xml | 19 +++++++++++++++++++ tests/unit/modules/zypper_test.py | 25 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/unit/modules/zypp/zypper-download.xml diff --git a/tests/unit/modules/rpm_test.py b/tests/unit/modules/rpm_test.py index f180736..4042137 100644 --- a/tests/unit/modules/rpm_test.py +++ b/tests/unit/modules/rpm_test.py @@ -95,6 +95,22 @@ class RpmTestCase(TestCase): self.assertDictEqual(rpm.owner('/usr/bin/python', '/usr/bin/vim'), ret) + # 'checksum' function tests: 1 + + def test_checksum(self): + ''' + Test if checksum validate as expected + ''' + ret = { + "file1.rpm": True, + "file2.rpm": False, + "file3.rpm": False, + } + + mock = MagicMock(side_effect=[True, 0, True, 1, False, 0]) + with patch.dict(rpm.__salt__, {'file.file_exists': mock, 'cmd.retcode': mock}): + self.assertDictEqual(rpm.checksum("file1.rpm", "file2.rpm", "file3.rpm"), ret) + @patch('salt.modules.rpm.HAS_RPM', True) def test_version_cmp_rpm(self): ''' diff --git a/tests/unit/modules/zypp/zypper-download.xml b/tests/unit/modules/zypp/zypper-download.xml new file mode 100644 index 0000000..eeea0a5 --- /dev/null +++ b/tests/unit/modules/zypp/zypper-download.xml @@ -0,0 +1,19 @@ +<?xml version='1.0'?> +<stream> + <message type="info">Loading repository data...</message> + <message type="info">Reading installed packages...</message> + <message type="warning">Argument resolves to no package: foo</message> + <progress id="" name="(1/1) /var/cache/zypp/packages/SLE-12-x86_64-Pool/x86_64/nmap-6.46-1.72.x86_64.rpm"/> + <download-result> + <solvable> + <kind>package</kind> + <name>nmap</name> + <edition epoch="0" version="6.46" release="1.72"/> + <arch>x86_64</arch> + <repository name="SLE-12-x86_64-Pool" alias="SLE-12-x86_64-Pool"/> + </solvable> + <localfile path="/var/cache/zypp/packages/SLE-12-x86_64-Pool/x86_64/nmap-6.46-1.72.x86_64.rpm"/> + </download-result> + <progress id="" name="(1/1) /var/cache/zypp/packages/SLE-12-x86_64-Pool/x86_64/nmap-6.46-1.72.x86_64.rpm" done="0"/> + <message type="info">download: Done.</message> +</stream> diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py index 4e735cd..9ec2b83 100644 --- a/tests/unit/modules/zypper_test.py +++ b/tests/unit/modules/zypper_test.py @@ -354,6 +354,31 @@ class ZypperTestCase(TestCase): self.assertTrue(pkgs.get(pkg_name)) self.assertEqual(pkgs[pkg_name], pkg_version) + def test_download(self): + ''' + Test package download + :return: + ''' + download_out = { + 'stdout': get_test_data('zypper-download.xml'), + 'stderr': None, + 'retcode': 0 + } + + test_out = { + 'nmap': { + 'path': u'/var/cache/zypp/packages/SLE-12-x86_64-Pool/x86_64/nmap-6.46-1.72.x86_64.rpm', + 'repository-alias': u'SLE-12-x86_64-Pool', + 'repository-name': u'SLE-12-x86_64-Pool' + } + } + + with patch.dict(zypper.__salt__, {'cmd.run_all': MagicMock(return_value=download_out)}): + with patch.dict(zypper.__salt__, {'lowpkg.checksum': MagicMock(return_value=True)}): + self.assertEqual(zypper.download("nmap"), test_out) + test_out['_error'] = "The following package(s) failed to download: foo" + self.assertEqual(zypper.download("nmap", "foo"), test_out) + def test_remove_purge(self): ''' Test package removal -- 2.8.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor