Add vm.launch testcase

This was a leftover from another patchset. Adding a test
for the vm.launch method.

Change-Id: I19ab411f852a18c68f61688c43e8e6579b385748
This commit is contained in:
Andreas Scheuring 2017-02-01 11:05:27 +01:00 committed by preethipy
parent eb2bc80389
commit 324bf8f3b3
1 changed files with 17 additions and 0 deletions

View File

@ -161,3 +161,20 @@ class VmHBATestCase(TestCase):
@mock.patch.object(vm.LOG, 'debug')
def test_attach_hba(self, mock_debug):
self.inst.attach_hbas(self.conf)
class InstancePartitionLifecycleTestCase(TestCase):
@mock.patch.object(vm.PartitionInstance, "_loop_status_update")
def test_launch(self, mock_loop_stat_upd):
mock_part = mock.Mock()
mock_inst = mock.Mock()
with mock.patch.object(vm.PartitionInstance, "get_partition",
return_value=mock_part):
part_inst = vm.PartitionInstance(mock_inst, None, None)
part_inst._boot_os_specific_parameters = "foo"
part_inst.launch()
self.assertEqual("building", mock_inst.vm_state)
self.assertEqual("spawning", mock_inst.task_state)
mock_inst.save.assert_called_once()
mock_part.start.assert_called_once_with(True)