_STATEINVALID_EXPL = 'Unable to update port state with specified value.'
_PORTINUSE_EXPL = 'A resource is currently attached to the logical port'
_ALREADYATTACHED_EXPL = 'The resource is already attached to another port'
+_NOTIMPLEMENTED_EXPL = 'Not implemented'
class QuantumHTTPError(webob.exc.HTTPClientError):
'code': 440,
'title': 'alreadyAttached',
'explanation': _ALREADYATTACHED_EXPL
+ },
+ exceptions.NotImplementedError: {
+ 'code': 501,
+ 'title': 'notImplemented',
+ 'explanation': _NOTIMPLEMENTED_EXPL
}
}
430: exceptions.PortNotFound,
431: exceptions.StateInvalid,
432: exceptions.PortInUseClient,
- 440: exceptions.AlreadyAttachedClient}
+ 440: exceptions.AlreadyAttachedClient,
+ 501: exceptions.NotImplementedError}
AUTH_TOKEN_HEADER = "X-Auth-Token"
import unittest
from quantum.tests.unit import BaseTest
from webtest import TestApp
+from webtest import AppError
from quantum import wsgi
+from quantum.api import faults
from quantum.common import config
+from quantum.common import exceptions
from quantum.common import extensions
import sys
print sys.path
def show(self, request, id):
return {'data': {'id': id}}
+ def notimplemented_function(self, request, id):
+ return faults.QuantumHTTPError(
+ exceptions.NotImplementedError("notimplemented_function"))
+
def custom_member_action(self, request, id):
return {'member_action': 'value'}
def custom_collection_action(self, request, **kwargs):
return {'collection': 'value'}
+ def test_exceptions_notimplemented(self):
+ controller = self.ResourceExtensionController()
+ member = {'notimplemented_function': "GET"}
+ res_ext = extensions.ResourceExtension('tweedles', controller,
+ member_actions=member)
+ test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext))
+
+ # Ideally we would check for a 501 code here but webtest doesn't take
+ # anything that is below 200 or above 400 so we can't actually check
+ # it. It thows AppError instead.
+ try:
+ response = \
+ test_app.get("/tweedles/some_id/notimplemented_function")
+ # Shouldn't be reached
+ self.assertTrue(False)
+ except AppError:
+ pass
+
def test_resource_can_be_added_as_extension(self):
res_ext = extensions.ResourceExtension('tweedles',
self.ResourceExtensionController())