Commit d2fd6234 authored by Georgios D. Tsoukalas's avatar Georgios D. Tsoukalas

cyclades: fix URLs in cyclades/vmapi tests

parent 90f572fd
......@@ -38,8 +38,34 @@ from django.utils import simplejson as json
from synnefo.lib import join_urls
from synnefo.vmapi import settings
from synnefo.cyclades_settings import cyclades_services, BASE_HOST
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
class VMAPITest(TestCase):
def setUp(self, *args, **kwargs):
super(VMAPITest, self).setUp(*args, **kwargs)
self.api_path = get_service_path(cyclades_services, 'vmapi',
version='v1.0')
def myget(self, path, *args, **kwargs):
path = join_urls(self.api_path, path)
return self.client.get(path, *args, **kwargs)
def myput(self, path, *args, **kwargs):
path = join_urls(self.api_path, path)
return self.client.put(path, *args, **kwargs)
def mypost(self, path, *args, **kwargs):
path = join_urls(self.api_path, path)
return self.client.post(path, *args, **kwargs)
def mydelete(self, path, *args, **kwargs):
path = join_urls(self.api_path, path)
return self.client.delete(path, *args, **kwargs)
class TestServerParams(TestCase):
class TestServerParams(VMAPITest):
def test_cache_backend(self):
from synnefo.vmapi import backend
......@@ -68,8 +94,8 @@ class TestServerParams(TestCase):
uuid = create_server_params(sender=vm, created_vm_params=params)
self.assertEqual(vm.config_url,
join_urls(settings.BASE_URL,
'/vmapi/server-params/%s' % uuid))
join_urls(BASE_HOST, self.api_path,
'server-params/%s' % uuid))
key = "vmapi_%s" % uuid
self.assertEqual(type(backend.get(key)), str)
data = json.loads(backend.get(key))
......@@ -77,7 +103,7 @@ class TestServerParams(TestCase):
self.assertEqual('personality' in data, True)
self.assertEqual(data.get('password'), 'X^942Jjfdsa')
response = self.client.get('/vmapi/server-params/%s' % uuid)
response = self.myget('server-params/%s' % uuid)
self.assertEqual(response.status_code, 200)
response = self.client.get('/vmapi/server-params/%s' % uuid)
response = self.myget('server-params/%s' % uuid)
self.assertEqual(response.status_code, 404)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment