Commit 74be46f4 authored by Georgios D. Tsoukalas's avatar Georgios D. Tsoukalas
Browse files

cyclades: add tests for 400 on wrong Compute paths

parent 1f4da53c
......@@ -136,3 +136,11 @@ class FlavorAPITest(BaseAPITest):
# XXX: flavors/22 below fails for no apparent reason
response = self.myget('flavors/%d' % 23)
self.assertItemNotFound(response)
def test_catch_wrong_api_paths(self, *args):
response = self.myget('nonexistent')
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
......@@ -213,6 +213,15 @@ class ImageAPITest(ComputeAPITest):
mimage.return_value.unregister.assert_called_once_with('42')
mimage.return_value._delete.assert_not_called('42')
@assert_backend_closed
def test_catch_wrong_api_paths(self, *args):
response = self.myget('nonexistent')
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
@patch('synnefo.plankton.backend.ImageBackend')
class ImageMetadataAPITest(ComputeAPITest):
......
......@@ -433,3 +433,11 @@ class NetworkAPITest(ComputeAPITest):
response = self.mypost('networks/%d/action' % net.id,
net.userid, json.dumps(request), 'json')
self.assertBadRequest(response)
def test_catch_wrong_api_paths(self, *args):
response = self.myget('nonexistent')
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
......@@ -189,6 +189,14 @@ class ServerAPITest(ComputeAPITest):
self.assertSuccess(response)
self.assertEqual(VirtualMachine.objects.get(id=vm.id).name, "new_name")
def test_catch_wrong_api_paths(self):
response = self.myget('nonexistent')
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
@patch('synnefo.api.util.get_image')
@patch('synnefo.logic.rapi_pool.GanetiRapiClient')
......
......@@ -36,6 +36,8 @@ from django.test import TestCase
from snf_django.utils.testing import astakos_user
from synnefo.cyclades_settings import cyclades_services
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
class APITest(TestCase):
def test_api_version(self):
......@@ -48,3 +50,13 @@ class APITest(TestCase):
api_version = json.loads(response.content)['version']
self.assertEqual(api_version['id'], 'v2.0')
self.assertEqual(api_version['status'], 'CURRENT')
def test_catch_wrong_api_paths(self, *args):
path = get_service_path(cyclades_services,
'compute', version='v2.0')
response = self.client.get(join_urls(path, 'nonexistent'))
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
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