"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/integration/modules/test_pkg.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_pkg.py  (salt-3002.1):test_pkg.py  (salt-3002.2)
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import os import os
import pprint import pprint
import pytest import pytest
import salt.utils.path import salt.utils.path
import salt.utils.pkg import salt.utils.pkg
import salt.utils.platform import salt.utils.platform
from tests.support.case import ModuleCase from tests.support.case import ModuleCase
from tests.support.helpers import ( from tests.support.helpers import (
destructiveTest, destructiveTest,
skipping to change at line 116 skipping to change at line 112
) )
self.assertEqual( self.assertEqual(
ret["uri"], ret["uri"],
uri, uri,
msg="The URI did not match. Full return:\n{}".format( msg="The URI did not match. Full return:\n{}".format(
pprint.pformat(ret) pprint.pformat(ret)
), ),
) )
elif grains["os_family"] == "RedHat": elif grains["os_family"] == "RedHat":
repo = "saltstack" repo = "saltstack"
name = "SaltStack repo for RHEL/CentOS {0}".format( name = "SaltStack repo for RHEL/CentOS {}".format(
grains["osmajorrelease"] grains["osmajorrelease"]
) )
baseurl = "http://repo.saltstack.com/yum/redhat/{0}/x86_64/lates t/".format( baseurl = "http://repo.saltstack.com/yum/redhat/{}/x86_64/latest /".format(
grains["osmajorrelease"] grains["osmajorrelease"]
) )
gpgkey = "https://repo.saltstack.com/yum/rhel{0}/SALTSTACK-GPG-K EY.pub".format( gpgkey = "https://repo.saltstack.com/yum/rhel{}/SALTSTACK-GPG-KE Y.pub".format(
grains["osmajorrelease"] grains["osmajorrelease"]
) )
gpgcheck = 1 gpgcheck = 1
enabled = 1 enabled = 1
ret = self.run_function( ret = self.run_function(
"pkg.mod_repo", "pkg.mod_repo",
[repo], [repo],
name=name, name=name,
baseurl=baseurl, baseurl=baseurl,
gpgkey=gpgkey, gpgkey=gpgkey,
skipping to change at line 421 skipping to change at line 417
# used to get an overview of the available packages. We should # used to get an overview of the available packages. We should
# try to find packages with few dependencies and small download # try to find packages with few dependencies and small download
# sizes, to keep this test from taking longer than necessary. # sizes, to keep this test from taking longer than necessary.
self.fail("No suitable package found for this test") self.fail("No suitable package found for this test")
# Make sure we have the 2nd-oldest available version installed # Make sure we have the 2nd-oldest available version installed
ret = self.run_function("pkg.install", [target], version=old) ret = self.run_function("pkg.install", [target], version=old)
if not isinstance(ret, dict): if not isinstance(ret, dict):
if ret.startswith("ERROR"): if ret.startswith("ERROR"):
self.skipTest( self.skipTest(
"Could not install older {0} to complete " "Could not install older {} to complete " "test.".format
"test.".format(target) (target)
) )
# Run a system upgrade, which should catch the fact that the # Run a system upgrade, which should catch the fact that the
# targeted package needs upgrading, and upgrade it. # targeted package needs upgrading, and upgrade it.
ret = self.run_function(func) ret = self.run_function(func)
# The changes dictionary should not be empty. # The changes dictionary should not be empty.
if "changes" in ret: if "changes" in ret:
self.assertIn(target, ret["changes"]) self.assertIn(target, ret["changes"])
else: else:
skipping to change at line 465 skipping to change at line 460
@slowTest @slowTest
def test_pkg_latest_version(self, grains): def test_pkg_latest_version(self, grains):
""" """
Check that pkg.latest_version returns the latest version of the uninstal led package. Check that pkg.latest_version returns the latest version of the uninstal led package.
The package is not installed. Only the package version is checked. The package is not installed. Only the package version is checked.
""" """
self.run_state("pkg.removed", name=self.pkg) self.run_state("pkg.removed", name=self.pkg)
cmd_pkg = [] cmd_pkg = []
if grains["os_family"] == "RedHat": if grains["os_family"] == "RedHat":
cmd_pkg = self.run_function("cmd.run", ["yum list {0}".format(self.p kg)]) cmd_pkg = self.run_function("cmd.run", ["yum list {}".format(self.pk g)])
elif salt.utils.platform.is_windows(): elif salt.utils.platform.is_windows():
cmd_pkg = self.run_function("pkg.list_available", [self.pkg]) cmd_pkg = self.run_function("pkg.list_available", [self.pkg])
elif grains["os_family"] == "Debian": elif grains["os_family"] == "Debian":
cmd_pkg = self.run_function("cmd.run", ["apt list {0}".format(self.p kg)]) cmd_pkg = self.run_function("cmd.run", ["apt list {}".format(self.pk g)])
elif grains["os_family"] == "Arch": elif grains["os_family"] == "Arch":
cmd_pkg = self.run_function("cmd.run", ["pacman -Si {0}".format(self .pkg)]) cmd_pkg = self.run_function("cmd.run", ["pacman -Si {}".format(self. pkg)])
elif grains["os_family"] == "FreeBSD": elif grains["os_family"] == "FreeBSD":
cmd_pkg = self.run_function( cmd_pkg = self.run_function(
"cmd.run", ["pkg search -S name -qQ version -e {0}".format(self. pkg)] "cmd.run", ["pkg search -S name -qQ version -e {}".format(self.p kg)]
) )
elif grains["os_family"] == "Suse": elif grains["os_family"] == "Suse":
cmd_pkg = self.run_function("cmd.run", ["zypper info {0}".format(sel f.pkg)]) cmd_pkg = self.run_function("cmd.run", ["zypper info {}".format(self .pkg)])
elif grains["os_family"] == "MacOS": elif grains["os_family"] == "MacOS":
brew_bin = salt.utils.path.which("brew") brew_bin = salt.utils.path.which("brew")
mac_user = self.run_function("file.get_user", [brew_bin]) mac_user = self.run_function("file.get_user", [brew_bin])
if mac_user == "root": if mac_user == "root":
self.skipTest( self.skipTest(
"brew cannot run as root, try a user in {}".format( "brew cannot run as root, try a user in {}".format(
os.listdir("/Users/") os.listdir("/Users/")
) )
) )
cmd_pkg = self.run_function( cmd_pkg = self.run_function(
"cmd.run", ["brew info {0}".format(self.pkg)], run_as=mac_user "cmd.run", ["brew info {}".format(self.pkg)], run_as=mac_user
) )
else: else:
self.skipTest( self.skipTest(
"TODO: test not configured for {}".format(grains["os_family"]) "TODO: test not configured for {}".format(grains["os_family"])
) )
pkg_latest = self.run_function("pkg.latest_version", [self.pkg]) pkg_latest = self.run_function("pkg.latest_version", [self.pkg])
self.assertIn(pkg_latest, cmd_pkg) self.assertIn(pkg_latest, cmd_pkg)
 End of changes. 11 change blocks. 
15 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)