X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=api%2Fresources%2Fv2%2Ftestcases.py;h=ca88e9856e430fcece31ef71aacbb2cba408677b;hb=d1688a9d1ef8f6005e4d45e108fc52fea837d32b;hp=a14543c6649fbc118137ebdf6172581f05abd04f;hpb=4d693a81dcd25e4ec86cbc0fc99c562a8496c279;p=yardstick.git diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py index a14543c66..ca88e9856 100644 --- a/api/resources/v2/testcases.py +++ b/api/resources/v2/testcases.py @@ -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})