diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-02 23:48:42 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-02 23:50:51 +0000 |
| commit | fe87151dacebcf1b1e7475247b4e156f3c2295c5 (patch) | |
| tree | aae4a1365f764334e912c15720d3f29bd77bfe6c | |
| parent | 665c453ec2c1c8cc7ccdd5870fbbf0c01e2cf2db (diff) | |
Fix test_migrate_disk_and_power_off_exception
The test asserts that Exception is raised, which means any number of
failures within the test itself will cause it to pass. In this case
there were two bugs in the test case:
1) Too many arguments to migrate_disk_and_power_off
2) fake_get_instance_disk_info should return a JSON string
I changed the assert to catch an AssertionError exception instead to
avoid this kind of bug in the future
Change-Id: I5e0f57b093ee1b2830696542d343c2dd89c383d6
| -rw-r--r-- | nova/tests/test_libvirt.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 6c609cca8..a48b02f39 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -2122,7 +2122,7 @@ class LibvirtConnectionTestCase(test.TestCase): self.counter = 0 def fake_get_instance_disk_info(instance): - return [] + return '[]' def fake_destroy(instance, network_info, cleanup=True): pass @@ -2133,8 +2133,7 @@ class LibvirtConnectionTestCase(test.TestCase): def fake_execute(*args, **kwargs): self.counter += 1 if self.counter == 1: - raise Exception() - pass + assert False, "intentional failure" def fake_os_path_exists(path): return True @@ -2148,9 +2147,10 @@ class LibvirtConnectionTestCase(test.TestCase): self.stubs.Set(os.path, 'exists', fake_os_path_exists) ins_ref = self._create_instance() - self.assertRaises(Exception, - self.libvirtconnection.migrate_disk_and_power_off, - None, ins_ref, [], '10.0.0.2', None, None) + + self.assertRaises(AssertionError, + self.libvirtconnection.migrate_disk_and_power_off, + None, ins_ref, '10.0.0.2', None, None) def test_migrate_disk_and_power_off(self): """Test for nova.virt.libvirt.connection.LivirtConnection |
