aboutsummaryrefslogtreecommitdiffstats
path: root/api/resources/v2
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-07-21 01:14:10 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-21 01:14:10 +0000
commitca43ec6fa7e3f39bc4a6172e9522167f375b0797 (patch)
treec1ff1acc2f17197d39dc1767842a5511e8a922f7 /api/resources/v2
parent803844911ceb1886d8ff3bacc228bfe7aad2383b (diff)
parentad05b5ad5c70a6cc7026ce57309a9bdb9b317f79 (diff)
Merge "Add API(v2) to upload test case"
Diffstat (limited to 'api/resources/v2')
-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})