aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-07-20 03:30:58 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-07-20 03:30:58 +0000
commitad05b5ad5c70a6cc7026ce57309a9bdb9b317f79 (patch)
tree354de72c65d60c69ca2b108e0d983c7411012ab2
parentdf77b6585cb54d2e4691b946ea1bc9cca637c108 (diff)
Add API(v2) to upload test case
JIRA: YARDSTICK-742 API: /api/v2/yardstick/testcases/action METHOD: POST PARAMS: { 'action': 'upload_case', 'args': { 'file': file } } Change-Id: Id305e72a24ec28295ac4bae5e5b9ad83eb2c1e34 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
-rw-r--r--api/resources/v2/testcases.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py
new file mode 100644
index 000000000..119d0e230
--- /dev/null
+++ b/api/resources/v2/testcases.py
@@ -0,0 +1,28 @@
+import logging
+import os
+
+from api import ApiResource
+from yardstick.common.utils import result_handler
+from yardstick.common import constants as consts
+
+LOG = logging.getLogger(__name__)
+LOG.setLevel(logging.DEBUG)
+
+
+class V2Testcases(ApiResource):
+
+ def post(self):
+ return self._dispatch_post()
+
+ def upload_case(self, args):
+ try:
+ upload_file = args['file']
+ except KeyError:
+ return result_handler(consts.API_ERROR, 'file must be provided')
+
+ case_name = os.path.join(consts.TESTCASE_DIR, upload_file.filename)
+
+ LOG.info('save case file')
+ upload_file.save(case_name)
+
+ return result_handler(consts.API_SUCCESS, {'testcase': upload_file.filename})