[Kimchi-devel] [PATCH] [Kimchi 3/8] Mock default storage pools and networks for testing

Lucio Correia luciojhc at linux.vnet.ibm.com
Fri Mar 10 22:06:06 UTC 2017


Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 tests/test_model.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/test_model.py b/tests/test_model.py
index e1b957c..64085a0 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -86,8 +86,28 @@ NON_NUMA_XML = """
   </features>
 </domain>"""
 
+net_validate_patch = None
+net_validate = None
+
 
 def setUpModule():
+    global net_validate_patch
+    global net_validate
+
+    # mock default networks
+    config = {'method.return_value': True}
+    net_validate_patch = mock.patch('wok.plugins.kimchi.model.templates.'
+                                    'LibvirtVMTemplate._network_validate',
+                                    **config)
+    net_validate = net_validate_patch.start()
+
+    # mock osinfo defaults
+    osinfo.defaults['networks'] = []
+    osinfo.DEFAULT_POOLS = {
+        'default': DEFAULT_DIR,
+        'ISO': ISO_DIR,
+    }
+
     print __file__, "creating pools at", BASE_DIR
     os.makedirs(DEFAULT_DIR)
     os.makedirs(ISO_DIR)
@@ -105,6 +125,9 @@ def setUpModule():
 
 
 def tearDownModule():
+    global net_validate_patch
+    net_validate_patch.stop()
+
     # Model will create default and ISO storagepools at /var/tmp: delete them.
     conn = libvirt.open('qemu:///session')
 
-- 
2.7.4



More information about the Kimchi-devel mailing list