6 from api import ApiResource
7 from yardstick.common.utils import result_handler
8 from yardstick.common import constants as consts
10 LOG = logging.getLogger(__name__)
11 LOG.setLevel(logging.DEBUG)
14 class V2Testsuites(ApiResource):
17 return self._dispatch_post()
19 def create_suite(self, args):
21 suite_name = args['name']
23 return result_handler(consts.API_ERROR, 'name must be provided')
26 testcases = args['testcases']
28 return result_handler(consts.API_ERROR, 'testcases must be provided')
30 testcases = [{'file_name': '{}.yaml'.format(t)} for t in testcases]
32 suite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name))
34 'schema': 'yardstick:suite:0.1',
36 'test_cases_dir': 'tests/opnfv/test_cases/',
37 'test_cases': testcases
40 LOG.info('write test suite')
41 with open(suite, 'w') as f:
42 yaml.dump(suite_content, f, default_flow_style=False)
44 return result_handler(consts.API_SUCCESS, {'suite': suite_name})