def test_get_mpkg_ids(self, get_pkg_id_mock): ''' Test getting the ids of a mpkg file ''' expected = ['com.apple.this', 'com.salt.other'] 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']] with patch.dict(macpackage.__salt__, {'cmd.run': mock}): out = macpackage.get_mpkg_ids('/path/to/file.mpkg') mock.assert_called_once_with('find /path/to -name *.pkg', python_shell=True) calls = [call('/tmp/dmg-X/file.pkg'), call('/tmp/dmg-X/other.pkg')] get_pkg_id_mock.assert_has_calls(calls) self.assertEqual(out, expected)
def test_get_mpkg_ids(self, get_pkg_id_mock): ''' Test getting the ids of a mpkg file ''' expected = ['com.apple.this', 'com.salt.other'] 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']] with patch.dict(macpackage.__salt__, {'cmd.run': mock}): out = macpackage.get_mpkg_ids('/path/to/file.mpkg') mock.assert_called_once_with('find /path/to -name *.pkg', python_shell=True) calls = [ call('/tmp/dmg-X/file.pkg'), call('/tmp/dmg-X/other.pkg') ] get_pkg_id_mock.assert_has_calls(calls) self.assertEqual(out, expected)