commit a3accf0379be7b17cc106970ffb243907a5d3790
Author: Georgios D. Tsoukalas <gtsouk@grnet.gr>
Date:   Wed Jun 12 15:34:32 2013 +0300

    cyclades: add tests for 400 on wrong Compute paths

diff --git a/snf-cyclades-app/synnefo/api/test/flavors.py b/snf-cyclades-app/synnefo/api/test/flavors.py
index 0e141dd..bc97987 100644
--- a/snf-cyclades-app/synnefo/api/test/flavors.py
+++ b/snf-cyclades-app/synnefo/api/test/flavors.py
@@ -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)
diff --git a/snf-cyclades-app/synnefo/api/test/images.py b/snf-cyclades-app/synnefo/api/test/images.py
index 9ae65c3..97d28ba 100644
--- a/snf-cyclades-app/synnefo/api/test/images.py
+++ b/snf-cyclades-app/synnefo/api/test/images.py
@@ -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):
diff --git a/snf-cyclades-app/synnefo/api/test/networks.py b/snf-cyclades-app/synnefo/api/test/networks.py
index 81a5985..736953a 100644
--- a/snf-cyclades-app/synnefo/api/test/networks.py
+++ b/snf-cyclades-app/synnefo/api/test/networks.py
@@ -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)
diff --git a/snf-cyclades-app/synnefo/api/test/servers.py b/snf-cyclades-app/synnefo/api/test/servers.py
index 8d2a29b..68066e5 100644
--- a/snf-cyclades-app/synnefo/api/test/servers.py
+++ b/snf-cyclades-app/synnefo/api/test/servers.py
@@ -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')
diff --git a/snf-cyclades-app/synnefo/api/test/versions.py b/snf-cyclades-app/synnefo/api/test/versions.py
index c3151d7..ed06f96 100644
--- a/snf-cyclades-app/synnefo/api/test/versions.py
+++ b/snf-cyclades-app/synnefo/api/test/versions.py
@@ -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)
