def test_get_pkg_id_dir_wildcard(self): ''' Test getting a package id from a directory with a wildcard ''' expected = ['com.apple.this'] mock = MagicMock(return_value='com.apple.this') with patch.dict(macpackage.__salt__, {'cmd.run': mock}): out = macpackage._get_pkg_id_dir('/tmp/dmg-X/*.pkg/') cmd = '/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" \'/tmp/dmg-X/*.pkg/Contents/Info.plist\'' mock.assert_called_once_with(cmd, python_shell=True) self.assertEqual(out, expected)
def test_get_pkg_id_dir_wildcard(self): """ Test getting a package id from a directory with a wildcard """ expected = ["com.apple.this"] mock = MagicMock(return_value="com.apple.this") with patch.dict(macpackage.__salt__, {"cmd.run": mock}): out = macpackage._get_pkg_id_dir("/tmp/dmg-X/*.pkg/") cmd = "/usr/libexec/PlistBuddy -c \"print :CFBundleIdentifier\" '/tmp/dmg-X/*.pkg/Contents/Info.plist'" mock.assert_called_once_with(cmd, python_shell=True) self.assertEqual(out, expected)
def test_get_pkg_id_dir(): """ Test getting a package id from a directory """ expected = ["com.apple.this"] mock = MagicMock(return_value="com.apple.this") with patch.dict(macpackage.__salt__, {"cmd.run": mock}): out = macpackage._get_pkg_id_dir("/tmp/dmg-X/") cmd = ('/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier"' " /tmp/dmg-X/Contents/Info.plist") mock.assert_called_once_with(cmd, python_shell=False) assert out == expected