summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorArmando Migliaccio <armando.migliaccio@citrix.com>2011-03-24 16:38:31 +0000
committerArmando Migliaccio <armando.migliaccio@citrix.com>2011-03-24 16:38:31 +0000
commitb7150a461ab2aaee3c0a0f7e2b6588ddd4324b52 (patch)
treea5c8540c7e3700f5b9db7db56123dda8eb3e8dc2 /nova/tests
parent0c779999a36186ae58343e169db6f2e71c9a3200 (diff)
Addressed issues raised by Rick Harris' review
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_vmwareapi.py50
1 files changed, 46 insertions, 4 deletions
diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py
index b31ac11f1..22b66010a 100644
--- a/nova/tests/test_vmwareapi.py
+++ b/nova/tests/test_vmwareapi.py
@@ -59,8 +59,7 @@ class VMWareAPIVMTestCase(test.TestCase):
glance_stubs.FakeGlance)
self.conn = vmwareapi_conn.get_connection(False)
- def _create_vm(self):
- """Create and spawn the VM."""
+ def _create_instance_in_the_db(self):
values = {'name': 1,
'id': 1,
'project_id': self.project.id,
@@ -72,6 +71,10 @@ class VMWareAPIVMTestCase(test.TestCase):
'mac_address': 'aa:bb:cc:dd:ee:ff',
}
self.instance = db.instance_create(values)
+
+ def _create_vm(self):
+ """Create and spawn the VM."""
+ self._create_instance_in_the_db()
self.type_data = db.instance_type_get_by_name(None, 'm1.large')
self.conn.spawn(self.instance)
self._check_vm_record()
@@ -139,6 +142,11 @@ class VMWareAPIVMTestCase(test.TestCase):
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
+ def test_snapshot_non_existent(self):
+ self._create_instance_in_the_db()
+ self.assertRaises(Exception, self.conn.snapshot, self.instance,
+ "Test-Snapshot")
+
def test_reboot(self):
self._create_vm()
info = self.conn.get_info(1)
@@ -147,6 +155,19 @@ class VMWareAPIVMTestCase(test.TestCase):
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
+ def test_reboot_non_existent(self):
+ self._create_instance_in_the_db()
+ self.assertRaises(Exception, self.conn.reboot, self.instance)
+
+ def test_reboot_not_poweredon(self):
+ self._create_vm()
+ info = self.conn.get_info(1)
+ self._check_vm_info(info, power_state.RUNNING)
+ self.conn.suspend(self.instance, self.dummy_callback_handler)
+ info = self.conn.get_info(1)
+ self._check_vm_info(info, power_state.PAUSED)
+ self.assertRaises(Exception, self.conn.reboot, self.instance)
+
def test_suspend(self):
self._create_vm()
info = self.conn.get_info(1)
@@ -155,6 +176,11 @@ class VMWareAPIVMTestCase(test.TestCase):
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED)
+ def test_suspend_non_existent(self):
+ self._create_instance_in_the_db()
+ self.assertRaises(Exception, self.conn.suspend, self.instance,
+ self.dummy_callback_handler)
+
def test_resume(self):
self._create_vm()
info = self.conn.get_info(1)
@@ -166,6 +192,18 @@ class VMWareAPIVMTestCase(test.TestCase):
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
+ def test_resume_non_existent(self):
+ self._create_instance_in_the_db()
+ self.assertRaises(Exception, self.conn.resume, self.instance,
+ self.dummy_callback_handler)
+
+ def test_resume_not_suspended(self):
+ self._create_vm()
+ info = self.conn.get_info(1)
+ self._check_vm_info(info, power_state.RUNNING)
+ self.assertRaises(Exception, self.conn.resume, self.instance,
+ self.dummy_callback_handler)
+
def test_get_info(self):
self._create_vm()
info = self.conn.get_info(1)
@@ -176,10 +214,14 @@ class VMWareAPIVMTestCase(test.TestCase):
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
instances = self.conn.list_instances()
- self.assertTrue(len(instances) == 1)
+ self.assertEquals(len(instances), 1)
self.conn.destroy(self.instance)
instances = self.conn.list_instances()
- self.assertTrue(len(instances) == 0)
+ self.assertEquals(len(instances), 0)
+
+ def test_destroy_non_existent(self):
+ self._create_instance_in_the_db()
+ self.assertEquals(self.conn.destroy(self.instance), None)
def test_pause(self):
pass