From e66428c34bde48ed4648a0628b86298cf26f5fb3 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Thu, 20 Jul 2017 03:52:34 +0000 Subject: Add API to delete certain test case JIRA: YARDSTICK-745 API: /api/v2/yardstick/testcases/ METHOD: DELETE Change-Id: Ic75ee60abfc00d20328ee45b9830dea1fe464482 Signed-off-by: chenjiankun --- api/resources/v2/testcases.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py index a14543c66..81b4aa88c 100644 --- a/api/resources/v2/testcases.py +++ b/api/resources/v2/testcases.py @@ -49,3 +49,14 @@ class V2Testcase(ApiResource): return result_handler(consts.API_ERROR, 'case does not exist') return result_handler(consts.API_SUCCESS, {'testcase': data}) + + def delete(self, case_name): + case_path = os.path.join(consts.TESTCASE_DIR, '{}.yaml'.format(case_name)) + + try: + os.remove(case_path) + except IOError as e: + if e.errno == errno.ENOENT: + return result_handler(consts.API_ERROR, 'case does not exist') + + return result_handler(consts.API_SUCCESS, {'testcase': case_name}) -- cgit 1.2.3-korg