Bugfix: missing license in api directory
[yardstick.git] / api / resources / v2 / testcases.py
index a14543c..ca88e98 100644 (file)
@@ -1,3 +1,11 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
 import logging
 import errno
 import os
@@ -49,3 +57,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})