def get(self): param = Param({}) testsuite_list = Testsuite().list_all(param) data = {'testsuites': testsuite_list} return result_handler(consts.API_SUCCESS, data)
def run_test_case(args): try: case_name = args['testcase'] except KeyError: return result_handler(consts.API_ERROR, 'testcase must be provided') testcase = os.path.join(consts.TESTCASE_DIR, '{}.yaml'.format(case_name)) task_id = str(uuid.uuid4()) task_args = {'inputfile': [testcase], 'task_id': task_id} task_args.update(args.get('opts', {})) param = Param(task_args) task_thread = TaskThread(Task().start, param) task_thread.start() return result_handler(consts.API_SUCCESS, {'task_id': task_id})
def run(self, args): try: task_id = args['task_id'] except KeyError: return result_handler(consts.API_ERROR, 'task_id must be provided') try: uuid.UUID(task_id) except ValueError: return result_handler(consts.API_ERROR, 'invalid task id') task_handler = V2TaskHandler() try: task = task_handler.get_by_uuid(task_id) except ValueError: return result_handler(consts.API_ERROR, 'no such task id') if not task.environment_id: return result_handler(consts.API_ERROR, 'environment not set') if not task.case_name or not task.content: return result_handler(consts.API_ERROR, 'case not set') if task.status == 0: return result_handler(consts.API_ERROR, 'task is already running') with open('/tmp/{}.yaml'.format(task.case_name), 'w') as f: f.write(task.content) data = { 'inputfile': ['/tmp/{}.yaml'.format(task.case_name)], 'task_id': task_id, 'task-args': task.params } if task.suite: data.update({'suite': True}) LOG.info('start task thread') param = Param(data) task_thread = TaskThread(Task().start, param, task_handler) task_thread.start() return result_handler(consts.API_SUCCESS, {'uuid': task_id})
def run_test_suite(self, args): try: name = args['testsuite'] except KeyError: return result_handler(consts.API_ERROR, 'testsuite must be provided') testsuite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(name)) task_id = str(uuid.uuid4()) task_args = { 'inputfile': [testsuite], 'task_id': task_id, 'suite': True } task_args.update(args.get('opts', {})) param = Param(task_args) task_thread = TaskThread(Task().start, param, TasksHandler()) task_thread.start() return result_handler(consts.API_SUCCESS, {'task_id': task_id})
def get(self): param = Param({}) testcase_list = Testcase().list_all(param) return result_handler(consts.API_SUCCESS, testcase_list)
def listAllTestcases(args): param = Param(args) testcase_list = Testcase().list_all(param) return common_utils.result_handler(1, testcase_list)
def change_osloobj_to_paras(args): param = Param({}) for k in vars(param): if hasattr(args, k): setattr(param, k, getattr(args, k)) return param
def _change_to_dict(self, args): p = Param({}) return {k: getattr(args, k) for k in vars(p) if hasattr(args, k)}