[Kimchi-devel] [PATCH 2/3] Fix test case: Delete directory associated to the storage pool

Aline Manera alinefm at linux.vnet.ibm.com
Thu Nov 12 19:32:41 UTC 2015


When creating a DIR storage pool using Model, a directory is created in
the system. It should be deleted after running the test case to avoid
leaving leftovers in the system and future problems when running the test
case multiple times.
So do it.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/wok/plugins/kimchi/tests/test_model_storagepool.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/wok/plugins/kimchi/tests/test_model_storagepool.py b/src/wok/plugins/kimchi/tests/test_model_storagepool.py
index 5f9b966..ef28bda 100644
--- a/src/wok/plugins/kimchi/tests/test_model_storagepool.py
+++ b/src/wok/plugins/kimchi/tests/test_model_storagepool.py
@@ -20,6 +20,7 @@
 
 import json
 import os
+import shutil
 import tempfile
 import unittest
 from functools import partial
@@ -72,11 +73,12 @@ class StoragepoolTests(unittest.TestCase):
             # Now add a couple of storage pools
             for i in xrange(3):
                 name = u'kīмсhī-storagepool-%i' % i
-                req = json.dumps({'name': name, 'type': 'dir',
-                                  'path': '/var/lib/libvirt/images/%i' % i})
+                path = '/var/lib/libvirt/images/%i' % i
+                req = json.dumps({'name': name, 'type': 'dir', 'path': path})
                 resp = self.request('/plugins/kimchi/storagepools', req,
                                     'POST')
                 rollback.prependDefer(model.storagepool_delete, name)
+                rollback.prependDefer(shutil.rmtree, path)
 
                 self.assertEquals(201, resp.status)
 
-- 
2.5.0




More information about the Kimchi-devel mailing list