summaryrefslogtreecommitdiffstats
path: root/api/resources/v2/testcases.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-07-20 03:46:17 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-07-20 03:46:17 +0000
commit423a206606c64552314263177f687671ffacb27a (patch)
treee905afddc04bd7478af162a02b42d4cc4e70d862 /api/resources/v2/testcases.py
parentc23de3d10294b85d6bb54191027fd3be983ce2f7 (diff)
Add API(v2) to get certain test case info
JIRA: YARDSTICK-744 API: /api/v2/yardstick/testcases METHOD: GET Change-Id: I4b1867f713bce2f9f2342ecec8540b08b0bb3456 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/resources/v2/testcases.py')
-rw-r--r--api/resources/v2/testcases.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py
index 3277b4c43..a14543c66 100644
--- a/api/resources/v2/testcases.py
+++ b/api/resources/v2/testcases.py
@@ -1,4 +1,5 @@
import logging
+import errno
import os
from api import ApiResource
@@ -33,3 +34,18 @@ class V2Testcases(ApiResource):
upload_file.save(case_name)
return result_handler(consts.API_SUCCESS, {'testcase': upload_file.filename})
+
+
+class V2Testcase(ApiResource):
+
+ def get(self, case_name):
+ case_path = os.path.join(consts.TESTCASE_DIR, '{}.yaml'.format(case_name))
+
+ try:
+ with open(case_path) as f:
+ data = f.read()
+ 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': data})