diff options
author | akhilbatra898 <akhil.batra@research.iiit.ac.in> | 2017-03-18 14:16:26 +0530 |
---|---|---|
committer | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-03-23 07:30:11 +0000 |
commit | 7d69a1eae658fae6c7437e0a8316312cb625acb5 (patch) | |
tree | b84b51d4160459f0ed1b2fd9da403f6ddcd12372 /qtip/api/controllers/plan.py | |
parent | 05ef2c4f46a9dc7a704a290eb15817c80a52c2e6 (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/plan.py')
-rw-r--r-- | qtip/api/controllers/plan.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/qtip/api/controllers/plan.py b/qtip/api/controllers/plan.py index 93836a32..00593878 100644 --- a/qtip/api/controllers/plan.py +++ b/qtip/api/controllers/plan.py @@ -9,30 +9,23 @@ import httplib -import connexion - +from qtip.api.controllers import common from qtip.base import error from qtip.loader import plan def list_plans(): - plan_list = list(plan.Plan.list_all()) - return plan_list, httplib.OK + plans = list(plan.Plan.list_all()) + plans_by_name = [p['name'] for p in plans] + return {'plans': plans_by_name}, httplib.OK +@common.check_endpoint_for_error(resource='Plan') def get_plan(name): - try: - plan_spec = plan.Plan(name) - return {'name': plan_spec.name, - 'abspath': plan_spec.abspath, - 'content': plan_spec.content}, httplib.OK - except error.NotFoundError: - return connexion.problem(httplib.NOT_FOUND, - 'Plan Not Found', - 'requested plan `' + name + '` not found.') + plan_spec = plan.Plan(name) + return plan_spec.content +@common.check_endpoint_for_error(resource='Plan', operation='Run') def run_plan(name, action="run"): - return connexion.problem(httplib.NOT_IMPLEMENTED, - 'Run a plan', - 'Plan runner not implemented') + raise error.ToBeDoneError('run_plan', 'plan') |