From 8fbde4936df0c3521704dfc8629bb94579277f79 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: 2012年5月17日 16:15:29 -0400 Subject: [PATCH] Add unit test coverage for bug 1000261. The fix for bug 1000261 updated some parsing code to handle updated output from qemu-img. This test case exercises this parsing code. Change-Id: I5c9592478823464317cc6d521b3240913e4ded92 --- nova/tests/test_libvirt.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index db804acee542..42dfdbfa7cea 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -2426,6 +2426,29 @@ disk size: 4.4M''', '')) libvirt_utils.fetch_image(context, target, image_id, user_id, project_id) + def test_get_disk_backing_file(self): + with_actual_path = False + + def fake_execute(*args, **kwargs): + if with_actual_path: + return ("some\n" + "output\n" + "backing file: /foo/bar/baz (actual path: /a/b/c)\n" + "...\n"), '' + else: + return ("some\n" + "output\n" + "backing file: /foo/bar/baz\n" + "...\n"), '' + + self.stubs.Set(utils, 'execute', fake_execute) + + out = libvirt_utils.get_disk_backing_file('') + self.assertEqual(out, 'baz') + with_actual_path = True + out = libvirt_utils.get_disk_backing_file('') + self.assertEqual(out, 'c') + class LibvirtConnectionTestCase(test.TestCase): """Test for nova.virt.libvirt.connection.LibvirtConnection."""

AltStyle によって変換されたページ (->オリジナル) /