[Kimchi-devel] [PATCH 6/6] Fix test cases to proper get the screenshot and debug report file

Aline Manera alinefm at linux.vnet.ibm.com
Wed Oct 21 23:40:50 UTC 2015


Kimchi uses relative path internally, so while creating tests you need
to make sure to proper set the absolute URI accordingly.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/wok/plugins/kimchi/tests/test_mockmodel.py | 2 +-
 src/wok/plugins/kimchi/tests/test_rest.py      | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/wok/plugins/kimchi/tests/test_mockmodel.py b/src/wok/plugins/kimchi/tests/test_mockmodel.py
index 4c7926f..54a1ac8 100644
--- a/src/wok/plugins/kimchi/tests/test_mockmodel.py
+++ b/src/wok/plugins/kimchi/tests/test_mockmodel.py
@@ -81,7 +81,7 @@ class MockModelTests(unittest.TestCase):
         resp1 = request(host, ssl_port, '/plugins/kimchi/vms/test-vm')
         rspBody = resp1.read()
         testvm_Data = json.loads(rspBody)
-        screenshotURL = testvm_Data['screenshot']
+        screenshotURL = '/' + testvm_Data['screenshot']
         time.sleep(5)
         resp2 = request(host, ssl_port, screenshotURL)
         self.assertEquals(200, resp2.status)
diff --git a/src/wok/plugins/kimchi/tests/test_rest.py b/src/wok/plugins/kimchi/tests/test_rest.py
index b7fa2e1..e6cfa5a 100644
--- a/src/wok/plugins/kimchi/tests/test_rest.py
+++ b/src/wok/plugins/kimchi/tests/test_rest.py
@@ -309,7 +309,7 @@ class RestTests(unittest.TestCase):
         self.assertEquals(400, resp.status)
 
         # Test screenshot
-        resp = self.request(vm['screenshot'], method='HEAD')
+        resp = self.request('/' + vm['screenshot'], method='HEAD')
         self.assertEquals(200, resp.status)
         self.assertTrue(resp.getheader('Content-type').startswith('image'))
 
@@ -1130,7 +1130,7 @@ class RestTests(unittest.TestCase):
         resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}', 'POST')
         vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
 
-        resp = self.request(vm['screenshot'], method='HEAD')
+        resp = self.request('/' + vm['screenshot'], method='HEAD')
         self.assertEquals(200, resp.status)
         self.assertTrue(resp.getheader('Content-type').startswith('image'))
 
@@ -1159,7 +1159,7 @@ class RestTests(unittest.TestCase):
         vm = json.loads(self.request('/plugins/kimchi/vms/test-vm').read())
         img_lnk = vm['screenshot']
         self.request('/plugins/kimchi/vms/test-vm', '{}', 'DELETE')
-        resp = self.request(img_lnk)
+        resp = self.request('/' + img_lnk)
         self.assertEquals(404, resp.status)
 
     def test_interfaces(self):
@@ -1317,7 +1317,7 @@ class RestTests(unittest.TestCase):
             resp = request(host, ssl_port,
                            '/plugins/kimchi/debugreports/report1')
             debugre = json.loads(resp.read())
-            resp = request(host, ssl_port, debugre['uri'])
+            resp = request(host, ssl_port, '/' + debugre['uri'])
             self.assertEquals(200, resp.status)
 
     def test_repositories(self):
-- 
2.1.0




More information about the Kimchi-devel mailing list