def test_start_new_vm(self): """ Tests starting a new VM. """ ret = {} ret["stderr"] = "vmctl: started vm 4 successfully, tty /dev/ttyp4" ret["retcode"] = 0 mock_cmd = MagicMock(return_value=ret) mock_status = MagicMock(return_value={}) expected = {"changes": True, "console": "/dev/ttyp4"} with patch.dict(vmctl.__salt__, {"cmd.run_all": mock_cmd}): with patch("salt.modules.vmctl.status", mock_status): res = vmctl.start("web1", bootpath="/bsd.rd", nics=2, disk="/disk.img") mock_cmd.assert_called_once_with( [ "vmctl", "start", "web1", "-i 2", "-b", "/bsd.rd", "-d", "/disk.img", ], output_loglevel="trace", python_shell=False, ) self.assertDictEqual(expected, res)
def test_start_existing_vm(self): ''' Tests starting a VM that is already defined. ''' ret = {} ret['stderr'] = 'vmctl: started vm 4 successfully, tty /dev/ttyp4' ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) expected = {'changes': True, 'console': '/dev/ttyp4'} with patch.dict(vmctl.__salt__, {'cmd.run_all': mock_cmd}): self.assertDictEqual(expected, vmctl.start('4'))
def test_start_existing_vm(self): """ Tests starting a VM that is already defined. """ ret = {} ret["stderr"] = "vmctl: started vm 4 successfully, tty /dev/ttyp4" ret["retcode"] = 0 mock_cmd = MagicMock(return_value=ret) expected = {"changes": True, "console": "/dev/ttyp4"} with patch.dict(vmctl.__salt__, {"cmd.run_all": mock_cmd}): self.assertDictEqual(expected, vmctl.start("4"))
def test_start_new_vm(self): ''' Tests starting a new VM. ''' ret = {} ret['stderr'] = 'vmctl: started vm 4 successfully, tty /dev/ttyp4' ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) mock_status = MagicMock(return_value={}) expected = {'changes': True, 'console': '/dev/ttyp4'} with patch.dict(vmctl.__salt__, {'cmd.run_all': mock_cmd}): with patch('salt.modules.vmctl.status', mock_status): res = vmctl.start('web1', bootpath='/bsd.rd', nics=2, disk='/disk.img') mock_cmd.assert_called_once_with([ 'vmctl', 'start', 'web1', '-i 2', '-b', '/bsd.rd', '-d', '/disk.img' ], output_loglevel='trace', python_shell=False) self.assertDictEqual(expected, res)