Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:jordimassaguerpla:branch:sUM:salt_fix
salt
remove-arch-from-name-when-pkg.list_pkgs-is-cal...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File remove-arch-from-name-when-pkg.list_pkgs-is-called-w.patch of Package salt
From 06482f99ed8bad5ffe5fb67182fd3aea166b8a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= <psuarezhernandez@suse.com> Date: Mon, 19 Nov 2018 11:46:26 +0000 Subject: [PATCH] Remove arch from name when pkg.list_pkgs is called with 'attr' (bsc#1114029) Add unit tests for pkg_resource.format_pkg_list Fix pylint issues Refactor: Return requested attr even if empty Add corner cases on package names to unit tests Fix Zypper/Yum unit test after returning empty requested attrs Add Yum/Zypper list_pkgs unit tests for multiple versions reported Compare testing items properly to avoid unwanted failures Use assertCountEqual when running on Python3 Add missing import for the six module Strip architecture from package name in aptpkg module Use parse_arch_from_name if available on the virtual pkg module Adapt unit tests after introducing parse_arch_from_name Use PKG_ARCH_SEPARATOR in pkg.normalize_name method Add pkg_resource to setup loader modules. Fix pylint Remove unnecessary lambda Return None instead empty string for arch and release in pkg.list_pkgs --- tests/unit/modules/test_zypperpkg.py | 49 +++++++++------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py index 36261285cb..7bff7065c6 100644 --- a/tests/unit/modules/test_zypperpkg.py +++ b/tests/unit/modules/test_zypperpkg.py @@ -1,33 +1,24 @@ -# -*- coding: utf-8 -*- """ :codeauthor: Bo Maryniuk <bo@suse.de> """ -# Import Python Libs -from __future__ import absolute_import import os from xml.dom import minidom import salt.modules.pkg_resource as pkg_resource import salt.modules.zypperpkg as zypper - -# Import Salt libs import salt.utils.files import salt.utils.pkg from salt.exceptions import CommandExecutionError from salt.ext import six - -# Import 3rd-party libs from salt.ext.six.moves import configparser - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, Mock, call, patch from tests.support.unit import TestCase -class ZyppCallMock(object): +class ZyppCallMock: def __init__(self, return_value=None): self.__return_value = return_value @@ -124,7 +115,7 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): :return: """ - class RunSniffer(object): + class RunSniffer: def __init__(self, stdout=None, stderr=None, retcode=None): self.calls = list() self._stdout = stdout or "" @@ -237,7 +228,7 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): ): with self.assertRaisesRegex( CommandExecutionError, - "^Zypper command failure: Some handled zypper internal error{0}Another zypper internal error$".format( + "^Zypper command failure: Some handled zypper internal error{}Another zypper internal error$".format( os.linesep ), ): @@ -316,7 +307,7 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): "--no-refresh", "--disable-repositories", "products", - u"-i", + "-i", ], env={"ZYPP_READONLY_HACK": "1"}, output_loglevel="trace", @@ -338,14 +329,9 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): "eol_t", "registerrelease", ]: - if six.PY3: - self.assertCountEqual( - test_data[kwd], [prod.get(kwd) for prod in products] - ) - else: - self.assertEqual( - test_data[kwd], sorted([prod.get(kwd) for prod in products]) - ) + self.assertCountEqual( + test_data[kwd], [prod.get(kwd) for prod in products] + ) cmd_run_all.assert_has_calls([mock_call]) def test_refresh_db(self): @@ -797,7 +783,7 @@ Use 'zypper repos' to get the list of defined repositories. Repository 'DUMMY' not found by its alias, number, or URI. """ - class FailingZypperDummy(object): + class FailingZypperDummy: def __init__(self): self.stdout = zypper_out self.stderr = "" @@ -1083,10 +1069,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. ], } for pkgname, pkginfo in pkgs.items(): - if six.PY3: - self.assertCountEqual(pkginfo, expected_pkg_list[pkgname]) - else: - self.assertItemsEqual(pkginfo, expected_pkg_list[pkgname]) + self.assertCountEqual(pkginfo, expected_pkg_list[pkgname]) def test_list_patches(self): """ @@ -1446,7 +1429,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. :return: """ - class ListPackages(object): + class ListPackages: def __init__(self): self._packages = ["vim", "pico"] self._pkgs = { @@ -1884,7 +1867,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. """ _zpr = MagicMock() _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc)) - assert isinstance(zypper.Wildcard(_zpr)("libzypp", "*.1"), six.string_types) + assert isinstance(zypper.Wildcard(_zpr)("libzypp", "*.1"), str) def test_wildcard_to_query_condition_preservation(self): """ @@ -1904,14 +1887,14 @@ Repository 'DUMMY' not found by its alias, number, or URI. for op in zypper.Wildcard.Z_OP: assert zypper.Wildcard(_zpr)( - "libzypp", "{0}*.1".format(op) - ) == "{0}17.2.6-27.9.1".format(op) + "libzypp", "{}*.1".format(op) + ) == "{}17.2.6-27.9.1".format(op) # Auto-fix feature: moves operator from end to front for op in zypper.Wildcard.Z_OP: assert zypper.Wildcard(_zpr)( - "libzypp", "16*{0}".format(op) - ) == "{0}16.2.5-25.1".format(op) + "libzypp", "16*{}".format(op) + ) == "{}16.2.5-25.1".format(op) def test_wildcard_to_query_unsupported_operators(self): """ @@ -1930,7 +1913,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc)) with self.assertRaises(CommandExecutionError): for op in [">>", "==", "<<", "+"]: - zypper.Wildcard(_zpr)("libzypp", "{0}*.1".format(op)) + zypper.Wildcard(_zpr)("libzypp", "{}*.1".format(op)) @patch("salt.modules.zypperpkg._get_visible_patterns") def test__get_installed_patterns(self, get_visible_patterns): -- 2.29.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