Beispiel #1
0
    def test_prlctl(self):
        '''
        Test parallels.prlctl
        '''
        runas = 'macdev'

        # Test missing prlctl binary
        with patch('salt.utils.path.which', MagicMock(return_value=False)):
            with self.assertRaises(CommandExecutionError):
                parallels.prlctl('info', runas=runas)

        # Simulate the existence of prlctl
        with patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/prlctl")):

            # Validate 'prlctl user list'
            user_cmd = ['prlctl', 'user', 'list']
            user_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {'cmd.run': user_fcn}):
                parallels.prlctl('user', 'list', runas=runas)
                user_fcn.assert_called_once_with(user_cmd, runas=runas)

            # Validate 'prlctl exec "macvm uname"'
            exec_cmd = ['prlctl', 'exec', 'macvm', 'uname']
            exec_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {'cmd.run': exec_fcn}):
                parallels.prlctl('exec', 'macvm uname', runas=runas)
                exec_fcn.assert_called_once_with(exec_cmd, runas=runas)

            # Validate 'prlctl capture "macvm --file macvm.display.png"'
            cap_cmd = ['prlctl', 'capture', 'macvm', '--file', 'macvm.display.png']
            cap_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {'cmd.run': cap_fcn}):
                parallels.prlctl('capture', 'macvm --file macvm.display.png', runas=runas)
                cap_fcn.assert_called_once_with(cap_cmd, runas=runas)
Beispiel #2
0
    def test_prlctl(self):
        '''
        Test parallels.prlctl
        '''
        runas = 'macdev'

        # Validate 'prlctl user list'
        user_cmd = ['prlctl', 'user', 'list']
        user_fcn = MagicMock()
        with patch.dict(parallels.__salt__, {'cmd.run': user_fcn}):
            parallels.prlctl('user', 'list', runas=runas)
            user_fcn.assert_called_once_with(user_cmd, runas=runas)

        # Validate 'prlctl exec macvm uname'
        exec_cmd = ['prlctl', 'exec', 'macvm', 'uname']
        exec_fcn = MagicMock()
        with patch.dict(parallels.__salt__, {'cmd.run': exec_fcn}):
            parallels.prlctl('exec', 'macvm uname', runas=runas)
            exec_fcn.assert_called_once_with(exec_cmd, runas=runas)
Beispiel #3
0
    def test_prlctl(self):
        '''
        Test parallels.prlctl
        '''
        runas = 'macdev'

        # Validate 'prlctl user list'
        user_cmd = ['prlctl', 'user', 'list']
        user_fcn = MagicMock()
        with patch.dict(parallels.__salt__, {'cmd.run': user_fcn}):
            parallels.prlctl('user', 'list', runas=runas)
            user_fcn.assert_called_once_with(user_cmd, runas=runas)

        # Validate 'prlctl exec "macvm uname"'
        exec_cmd = ['prlctl', 'exec', 'macvm', 'uname']
        exec_fcn = MagicMock()
        with patch.dict(parallels.__salt__, {'cmd.run': exec_fcn}):
            parallels.prlctl('exec', 'macvm uname', runas=runas)
            exec_fcn.assert_called_once_with(exec_cmd, runas=runas)

        # Validate 'prlctl capture "macvm --file macvm.display.png"'
        cap_cmd = ['prlctl', 'capture', 'macvm', '--file', 'macvm.display.png']
        cap_fcn = MagicMock()
        with patch.dict(parallels.__salt__, {'cmd.run': cap_fcn}):
            parallels.prlctl('capture', 'macvm --file macvm.display.png', runas=runas)
            cap_fcn.assert_called_once_with(cap_cmd, runas=runas)
Beispiel #4
0
    def test_prlctl(self):
        """
        Test parallels.prlctl
        """
        runas = "macdev"

        # Test missing prlctl binary
        with patch("salt.utils.path.which", MagicMock(return_value=False)):
            with self.assertRaises(CommandExecutionError):
                parallels.prlctl("info", runas=runas)

        # Simulate the existence of prlctl
        with patch("salt.utils.path.which",
                   MagicMock(return_value="/usr/bin/prlctl")):

            # Validate 'prlctl user list'
            user_cmd = ["prlctl", "user", "list"]
            user_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {"cmd.run": user_fcn}):
                parallels.prlctl("user", "list", runas=runas)
                user_fcn.assert_called_once_with(user_cmd, runas=runas)

            # Validate 'prlctl exec "macvm uname"'
            exec_cmd = ["prlctl", "exec", "macvm", "uname"]
            exec_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {"cmd.run": exec_fcn}):
                parallels.prlctl("exec", "macvm uname", runas=runas)
                exec_fcn.assert_called_once_with(exec_cmd, runas=runas)

            # Validate 'prlctl capture "macvm --file macvm.display.png"'
            cap_cmd = [
                "prlctl", "capture", "macvm", "--file", "macvm.display.png"
            ]
            cap_fcn = MagicMock()
            with patch.dict(parallels.__salt__, {"cmd.run": cap_fcn}):
                parallels.prlctl("capture",
                                 "macvm --file macvm.display.png",
                                 runas=runas)
                cap_fcn.assert_called_once_with(cap_cmd, runas=runas)