diff options
author | Rex Lee <limingjiang@huawei.com> | 2017-07-21 01:14:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-07-21 01:14:35 +0000 |
commit | 4d693a81dcd25e4ec86cbc0fc99c562a8496c279 (patch) | |
tree | 745970b0bf7975d7997dcb03e2d29daa31c22c99 /api | |
parent | e67df4eae64b9a5e1a5296c0066ce768e82d34f8 (diff) | |
parent | 423a206606c64552314263177f687671ffacb27a (diff) |
Merge "Add API(v2) to get certain test case info"
Diffstat (limited to 'api')
-rw-r--r-- | api/resources/v2/testcases.py | 16 |
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}) |