From nobody Thu Apr 25 06:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183681923254.8447457902421; Fri, 10 Mar 2017 14:08:01 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 15C7A8205D8; Fri, 10 Mar 2017 22:08:01 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 462708205D8 for ; Fri, 10 Mar 2017 22:06:37 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4Gjn104634 for ; Fri, 10 Mar 2017 17:06:36 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 293f4vcmjx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:36 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:31 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:30 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6TO031588542 for ; Fri, 10 Mar 2017 19:06:29 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6SnZ018299 for ; Fri, 10 Mar 2017 19:06:28 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKE018086; Fri, 10 Mar 2017 19:06:27 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:11 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17031022-0028-0000-0000-0000019EA799 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0029-0000-0000-0000149CC863 Message-Id: <1489183571-10933-9-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 8/8] Mock user probe functions X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Lucio Correia --- tests/test_model.py | 237 +++++++++++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 208 insertions(+), 29 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 4579ded..11c6fab 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -176,7 +176,13 @@ class ModelTests(unittest.TestCase): if os.path.isfile(self.tmp_store): os.unlink(self.tmp_store) =20 - def test_vm_info(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_info(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('test:///default', self.tmp_store) vms =3D inst.vms_get_list() self.assertEquals(1, len(vms)) @@ -381,8 +387,14 @@ class ModelTests(unittest.TestCase): info =3D inst.vm_lookup('kimchi-vm') self.assertEquals('running', info['state']) =20 - @unittest.skipUnless(os.uname()[4] !=3D "s390x", 'Not applicable to s3= 90x') - def test_vm_graphics(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + @unittest.skipUnless(os.uname()[4] !=3D 's390x', "Not applicable to s3= 90x") + def test_vm_graphics(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} @@ -408,7 +420,14 @@ class ModelTests(unittest.TestCase): =20 inst.template_delete('test') =20 - def test_vm_virtviewerfile_vmnotrunning(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_virtviewerfile_vmnotrunning(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} @@ -973,7 +992,14 @@ class ModelTests(unittest.TestCase): cur_cdrom_path =3D re.sub(":80/", '/', cdrom_info['path']) self.assertEquals(valid_remote_iso_path, cur_cdrom_path) =20 - def test_vm_storage_provisioning(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_storage_provisioning(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1030,7 +1056,15 @@ class ModelTests(unittest.TestCase): xpath =3D "/domain/devices/disk[@device=3D'disk']/driver/@type" return xpath_get_text(xml, xpath)[0] =20 - def test_template_get_default_vol_format_from_conf(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_get_default_vol_format_from_conf(self, + mock_probe_file_per= m, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1055,7 +1089,14 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, 'vmdk') =20 - def test_template_creates_user_defined_vol_format_instead_default(self= ): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_creates_user_defined_vol_format_instead_default( + self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 default_vol =3D 'vmdk' @@ -1083,7 +1124,14 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, user_vol) =20 - def test_template_uses_qcow2_format_if_no_user_or_default_defined(self= ): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_uses_qcow2_format_if_no_user_or_default_defined( + self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1218,7 +1266,14 @@ class ModelTests(unittest.TestCase): msg =3D "Memory hotplug in non-numa guests only for PowerPC arch." =20 @unittest.skipUnless(utils.running_as_root() and _host_is_power(), msg) - def test_non_numa_vm_memory_hotplug(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_non_numa_vm_memory_hotplug(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) conn =3D inst.conn.get() @@ -1462,29 +1517,51 @@ class ModelTests(unittest.TestCase): inst.vm_update(u'=D0=BFe=CF=89-=E2=88=A8=D0=BC', {"bootmenu": = False}) self.assertEquals("no", inst.vm_lookup(u'=D0=BFe=CF=89-=E2=88= =A8=D0=BC')['bootmenu']) =20 - def test_get_vm_cpu_cores(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_cores(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('2', inst.vm_get_vm_cpu_cores(xml)) =20 - def test_get_vm_cpu_sockets(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_sockets(self, mock_probe_file_perm, mock_probe_use= r): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('3', inst.vm_get_vm_cpu_sockets(xml)) =20 - def test_get_vm_cpu_threads(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_threads(self, mock_probe_file_perm, mock_probe_use= r): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('8', inst.vm_get_vm_cpu_threads(xml)) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_get_vm_cpu_topology(self, mock_has_topology): + def test_get_vm_cpu_topology(self, mock_has_topology, mock_probe_file_= perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1494,6 +1571,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D True expected_topology =3D {'sockets': 3, 'cores': 2, 'threads': 8} =20 @@ -1501,8 +1580,12 @@ class ModelTests(unittest.TestCase): self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_get_vm_cpu_topology_blank(self, mock_has_topology): + def test_get_vm_cpu_topology_blank(self, mock_has_topology, + mock_probe_file_perm, mock_probe_us= er): class FakeDom(): def XMLDesc(self, flag): return """""" @@ -1510,6 +1593,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D False expected_topology =3D {} =20 @@ -1517,15 +1602,27 @@ class ModelTests(unittest.TestCase): self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 - def test_vm_cpu_hotplug_invalidparam_fail(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_cpu_hotplug_invalidparam_fail(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 with self.assertRaisesRegexp(InvalidParameter, 'KCHCPUHOTP0001E'): params =3D {"cpu_info": {"vcpus": 1, 'maxvcpus': 4}} inst.vm_cpu_hotplug_precheck('', params) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_vm_cpu_hotplug_abovemax_fail(self, mock_has_topology): + def test_vm_cpu_hotplug_abovemax_fail(self, mock_has_topology, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1535,6 +1632,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D False inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 @@ -1542,10 +1641,15 @@ class ModelTests(unittest.TestCase): params =3D {"cpu_info": {"vcpus": 16}} inst.vm_cpu_hotplug_precheck(FakeDom(), params) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.get_vm_cpu_topology') def test_vm_cpu_hotplug_topology_mismatch_fail(self, mock_topology, - mock_has_topology): + mock_has_topology, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1555,6 +1659,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D True mock_topology.return_value =3D {'sockets': 3, 'cores': 2, 'threads= ': 8} =20 @@ -1564,16 +1670,28 @@ class ModelTests(unittest.TestCase): params =3D {"cpu_info": {"vcpus": 10}} inst.vm_cpu_hotplug_precheck(FakeDom(), params) =20 - def test_vm_cpu_hotplug_error(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_cpu_hotplug_error(self, mock_probe_file_perm, mock_probe_u= ser): class FakeDom(): def setVcpusFlags(self, vcpu, flags): raise libvirt.libvirtError('') =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) with self.assertRaisesRegexp(OperationFailed, 'KCHCPUHOTP0002E'): inst.vm_update_cpu_live(FakeDom(), '') =20 - def test_get_interfaces(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_interfaces(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) expected_ifaces =3D netinfo.all_favored_interfaces() ifaces =3D inst.interfaces_get_list() @@ -1586,7 +1704,10 @@ class ModelTests(unittest.TestCase): self.assertIn('ipaddr', iface) self.assertIn('netmask', iface) =20 - def test_async_tasks(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_async_tasks(self, mock_probe_file_perm, mock_probe_user): class task_except(Exception): pass =20 @@ -1610,6 +1731,9 @@ class ModelTests(unittest.TestCase): time.sleep(2) cb("step 3 OK", params.get('result', True)) =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) taskid =3D AsyncTask('', quick_op, 'Hello').id inst.task_wait(taskid) @@ -1664,7 +1788,13 @@ class ModelTests(unittest.TestCase): vms =3D inst.vms_get_list() self.assertFalse(u'k=C4=AB=D0=BC=D1=81h=C4=AB-=E2=88=A8=D0=BC'= in vms) =20 - def test_vm_list_sorted(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_list_sorted(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1683,7 +1813,13 @@ class ModelTests(unittest.TestCase): =20 self.assertEquals(vms, sorted(vms, key=3Dunicode.lower)) =20 - def test_vm_clone(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_clone(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('test:///default', objstore_loc=3Dself.tmp_st= ore) =20 all_vm_names =3D inst.vms_get_list() @@ -1733,7 +1869,13 @@ class ModelTests(unittest.TestCase): # (and removed) above (i.e. 'name' and 'uuid') self.assertEquals(original_vm, clone_vm) =20 - def test_use_test_host(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_use_test_host(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1758,7 +1900,13 @@ class ModelTests(unittest.TestCase): =20 self.assertTrue('kimchi-vm' in vms) =20 - def test_get_distros(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_distros(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) distros =3D inst.distros_get_list() for d in distros: @@ -1769,7 +1917,10 @@ class ModelTests(unittest.TestCase): self.assertIn('os_arch', distro) self.assertIn('path', distro) =20 - def test_deep_scan(self): + @mock.patch('wok.plugins.kimchi.model.storagevolumes.UserTests.probe_u= ser') + def test_deep_scan(self, mock_probe_user): + mock_probe_user.return_value =3D '' + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1796,7 +1947,14 @@ class ModelTests(unittest.TestCase): =20 @unittest.skipUnless(utils.running_as_root() and _host_is_power(), 'Only required for Power hosts') - def test_pci_hotplug_requires_usb_controller(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_pci_hotplug_requires_usb_controller(self, mock_probe_file_per= m, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) tpl_params =3D {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_IS= O} @@ -1896,7 +2054,14 @@ multifunction=3D'on'/> """ =20 - def test_vmhostdev_is_hostdev_multifunction(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vmhostdev_is_hostdev_multifunction(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 hostdev_multi_elem =3D objectify.fromstring( @@ -1913,7 +2078,14 @@ multifunction=3D'on'/> inst.vmhostdev_is_hostdev_multifunction(hostdev_nomulti_elem) ) =20 - def test_vmhostdev_get_devices_same_addr(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vmhostdev_get_devices_same_addr(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 root =3D objectify.fromstring(self.get_hostdevs_xml()) @@ -1947,12 +2119,19 @@ multifunction=3D'on'/> [ET.tostring(nomatch_elem)] ) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vmhostdevs.get_vm_config_flag') - def test_vmhostdev_unplug_multifunction_pci(self, mock_conf_flag): + def test_vmhostdev_unplug_multifunction_pci(self, mock_conf_flag, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def detachDeviceFlags(self, xml, config_flag): pass =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_conf_flag.return_value =3D '' =20 inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel