"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/modules/test_mac_package.py" between
salt-2019.2.0.tar.gz and salt-2019.2.1.tar.gz

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

test_mac_package.py  (salt-2019.2.0):test_mac_package.py  (salt-2019.2.1)
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Import Python libs # Import Python libs
from __future__ import absolute_import, unicode_literals, print_function from __future__ import absolute_import, unicode_literals, print_function
# Import Salt Libs # Import Salt Libs
import salt.modules.mac_package as macpackage import salt.modules.macpackage as macpackage
# Import Salt Testing Libs # Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase from tests.support.unit import TestCase
from tests.support.mock import ( from tests.support.mock import (
MagicMock, MagicMock,
patch, patch,
call call
) )
skipping to change at line 127 skipping to change at line 127
mock = MagicMock(return_value='com.apple.this\ncom.salt.that') mock = MagicMock(return_value='com.apple.this\ncom.salt.that')
with patch.dict(macpackage.__salt__, {'cmd.run': mock}): with patch.dict(macpackage.__salt__, {'cmd.run': mock}):
out = macpackage.installed_pkgs() out = macpackage.installed_pkgs()
mock.assert_called_once_with('pkgutil --pkgs') mock.assert_called_once_with('pkgutil --pkgs')
self.assertEqual(out, expected) self.assertEqual(out, expected)
def test_get_pkg_id_with_files(self): def test_get_pkg_id_with_files(self):
''' '''
Test getting a the id for a package Test getting a the id for a package
''' '''
with patch('salt.modules.mac_package._get_pkg_id_from_pkginfo') as pkg_i d_pkginfo_mock: with patch('salt.modules.macpackage._get_pkg_id_from_pkginfo') as pkg_id _pkginfo_mock:
expected = ['com.apple.this'] expected = ['com.apple.this']
cmd_mock = MagicMock(side_effect=[ cmd_mock = MagicMock(side_effect=[
'/path/to/PackageInfo\n/path/to/some/other/fake/PackageInfo', '/path/to/PackageInfo\n/path/to/some/other/fake/PackageInfo',
'', '',
'' ''
]) ])
pkg_id_pkginfo_mock.side_effect = [['com.apple.this'], []] pkg_id_pkginfo_mock.side_effect = [['com.apple.this'], []]
temp_mock = MagicMock(return_value='/tmp/dmg-ABCDEF') temp_mock = MagicMock(return_value='/tmp/dmg-ABCDEF')
remove_mock = MagicMock() remove_mock = MagicMock()
skipping to change at line 164 skipping to change at line 164
] ]
pkg_id_pkginfo_mock.assert_has_calls(pkg_id_pkginfo_calls) pkg_id_pkginfo_mock.assert_has_calls(pkg_id_pkginfo_calls)
remove_mock.assert_called_once_with('/tmp/dmg-ABCDEF') remove_mock.assert_called_once_with('/tmp/dmg-ABCDEF')
self.assertEqual(out, expected) self.assertEqual(out, expected)
def test_get_pkg_id_with_dir(self): def test_get_pkg_id_with_dir(self):
''' '''
Test getting a the id for a package with a directory Test getting a the id for a package with a directory
''' '''
with patch('salt.modules.mac_package._get_pkg_id_dir') as pkg_id_dir_moc k: with patch('salt.modules.macpackage._get_pkg_id_dir') as pkg_id_dir_mock :
expected = ['com.apple.this'] expected = ['com.apple.this']
pkg_id_dir_mock.return_value = ['com.apple.this'] pkg_id_dir_mock.return_value = ['com.apple.this']
cmd_mock = MagicMock(return_value='Error opening /path/to/file.pkg') cmd_mock = MagicMock(return_value='Error opening /path/to/file.pkg')
temp_mock = MagicMock(return_value='/tmp/dmg-ABCDEF') temp_mock = MagicMock(return_value='/tmp/dmg-ABCDEF')
remove_mock = MagicMock() remove_mock = MagicMock()
with patch.dict(macpackage.__salt__, {'cmd.run': cmd_mock, with patch.dict(macpackage.__salt__, {'cmd.run': cmd_mock,
'temp.dir': temp_mock, 'temp.dir': temp_mock,
'file.remove': remove_mock}): 'file.remove': remove_mock}):
out = macpackage.get_pkg_id('/path/to/file.pkg') out = macpackage.get_pkg_id('/path/to/file.pkg')
skipping to change at line 188 skipping to change at line 188
python_shell=True, output_logle vel='quiet') python_shell=True, output_logle vel='quiet')
pkg_id_dir_mock.assert_called_once_with('/path/to/file.pkg') pkg_id_dir_mock.assert_called_once_with('/path/to/file.pkg')
remove_mock.assert_called_once_with('/tmp/dmg-ABCDEF') remove_mock.assert_called_once_with('/tmp/dmg-ABCDEF')
self.assertEqual(out, expected) self.assertEqual(out, expected)
def test_get_mpkg_ids(self): def test_get_mpkg_ids(self):
''' '''
Test getting the ids of a mpkg file Test getting the ids of a mpkg file
''' '''
with patch('salt.modules.mac_package.get_pkg_id') as get_pkg_id_mock: with patch('salt.modules.macpackage.get_pkg_id') as get_pkg_id_mock:
expected = ['com.apple.this', 'com.salt.other'] expected = ['com.apple.this', 'com.salt.other']
mock = MagicMock(return_value='/tmp/dmg-X/file.pkg\n/tmp/dmg-X/other .pkg') mock = MagicMock(return_value='/tmp/dmg-X/file.pkg\n/tmp/dmg-X/other .pkg')
get_pkg_id_mock.side_effect = [['com.apple.this'], ['com.salt.other' ]] get_pkg_id_mock.side_effect = [['com.apple.this'], ['com.salt.other' ]]
with patch.dict(macpackage.__salt__, {'cmd.run': mock}): with patch.dict(macpackage.__salt__, {'cmd.run': mock}):
out = macpackage.get_mpkg_ids('/path/to/file.mpkg') out = macpackage.get_mpkg_ids('/path/to/file.mpkg')
mock.assert_called_once_with('find /path/to -name *.pkg', python _shell=True) mock.assert_called_once_with('find /path/to -name *.pkg', python _shell=True)
calls = [ calls = [
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

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