Port virt.libvirt.test_imagebackend to Python 3

* Don't compare mock with int on Python 3
* Can't compare None with int on Python 3
* Ensure libvirt secret is bytes

Partially-Implements: blueprint goal-python35

Change-Id: I564039f48f7b41798bb71768b6eeaf5d2f854a9c
This commit is contained in:
ChangBo Guo(gcb) 2016-11-23 16:00:37 +08:00
parent 7eb988da00
commit 91f8a02b2c
3 changed files with 3 additions and 6 deletions

View File

@ -365,6 +365,7 @@ class FlatTestCase(_ImageTestCase, test.NoDBTestCase):
return_value=imageutils.QemuImgInfo())
def test_create_image_extend(self, fake_qemu_img_info):
fn = self.prepare_mocks()
fake_qemu_img_info.return_value.virtual_size = 1024
fn(target=self.TEMPLATE_PATH, image_id=None)
imagebackend.libvirt_utils.copy_image(self.TEMPLATE_PATH, self.PATH)
image = imgmodel.LocalFileImage(self.PATH, imgmodel.FORMAT_RAW)
@ -1487,7 +1488,7 @@ class RbdTestCase(_ImageTestCase, test.NoDBTestCase):
self.INSTANCE["uuid"] + "_fake.vm",
"FakePool",
"FakeUser",
"MTIzNDU2Cg==",
b"MTIzNDU2Cg==",
["server1:1899", "server2:1920"]),
model)

View File

@ -685,7 +685,7 @@ class Lvm(Image):
def create_lvm_image(base, size):
base_size = disk.get_disk_size(base)
self.verify_base_size(base, size, base_size=base_size)
resize = size > base_size
resize = size > base_size if size else False
size = size if resize else base_size
lvm.create_volume(self.vg, self.lv,
size, sparse=self.sparse)

View File

@ -1,10 +1,6 @@
nova.tests.unit.api.openstack.compute.test_user_data.ServersControllerCreateTest
nova.tests.unit.test_wsgi.TestWSGIServerWithSSL
nova.tests.unit.virt.libvirt.test_firewall.IptablesFirewallTestCase
nova.tests.unit.virt.libvirt.test_imagebackend.EncryptedLvmTestCase
nova.tests.unit.virt.libvirt.test_imagebackend.LvmTestCase
nova.tests.unit.virt.libvirt.test_imagebackend.FlatTestCase
nova.tests.unit.virt.libvirt.test_imagebackend.RbdTestCase
nova.tests.unit.virt.libvirt.test_vif.LibvirtVifTestCase
nova.tests.unit.virt.xenapi.test_vm_utils.ResizeFunctionTestCase
nova.tests.unit.virt.xenapi.test_vm_utils.ScanSrTestCase