summaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/common.py
diff options
context:
space:
mode:
authorakhilbatra898 <akhil.batra@research.iiit.ac.in>2017-03-18 14:16:26 +0530
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-03-23 07:30:11 +0000
commit7d69a1eae658fae6c7437e0a8316312cb625acb5 (patch)
treeb84b51d4160459f0ed1b2fd9da403f6ddcd12372 /qtip/api/controllers/common.py
parent05ef2c4f46a9dc7a704a290eb15817c80a52c2e6 (diff)
Add unit tests for List and get in API.
- refactor controllers - remove abspath and other irrelvant data in response - move fixtures - refactor decorators JIRA: QTIP-226 Change-Id: I5fac5b1bc998da198098992e7ddb47ba49685f31 Signed-off-by: akhilbatra898 <akhil.batra@research.iiit.ac.in> (cherry picked from commit bef693f40ad87170b7233b9fef62f2fd8abfc8d8)
Diffstat (limited to 'qtip/api/controllers/common.py')
-rw-r--r--qtip/api/controllers/common.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/qtip/api/controllers/common.py b/qtip/api/controllers/common.py
index 6cabbc7f..96101f80 100644
--- a/qtip/api/controllers/common.py
+++ b/qtip/api/controllers/common.py
@@ -5,15 +5,22 @@ import connexion
from qtip.base import error
-def get_one_exceptions(resource):
+def check_endpoint_for_error(resource, operation=None):
def _decorator(func):
- def _execute(name):
+ def _execute(name=None):
try:
return func(name), httplib.OK
except error.NotFoundError:
return connexion.problem(
httplib.NOT_FOUND,
- '{} Not Found'.format(resource),
- 'Requested {} `{}` not found.'.format(resource, name))
+ '{} not found'.format(resource),
+ 'Requested {} `{}` not found.'
+ .format(resource.lower(), name))
+ except error.ToBeDoneError:
+ return connexion.problem(
+ httplib.NOT_IMPLEMENTED,
+ '{} handler not implemented'.format(operation),
+ 'Requested operation `{}` on {} not implemented.'
+ .format(operation.lower(), resource.lower()))
return _execute
return _decorator