How to use get_case_variables method in lisa

Best Python code snippet using lisa_python

functions.py

Source:functions.py Github

copy

Full Screen

...27 for case in self.cases:28 case_results = []29 skip = False30 path = get_case_path(case)31 variables = get_case_variables(case)32 operations = get_case_operations(case)33 repeat = case.repeat34 print 'start running a case'35 while repeat > 0:36 repeat -= 137 for operation in operations:38 if isinstance(operation, RequestOperation):39 request = Request(operation, variables)40 for result in request.excute(skip):41 print str(result)42 case_results.append(result['assert_result'])43 if operation.skip_next == 1 and not result["assert_result"] == "Pass":44 skip = True45 save_request_operation_log(self.report, path, result)46 if isinstance(operation, DBOperation):47 db = Database(operation, variables)48 for result in db.excute(skip):49 if operation.skip_next == 1 and not result["assert_result"] == "Pass":50 skip = True51 save_db_operation_log(self.report, path, result)52 update_report(self.report, case_results)53 self.report.end_time = datetime.now()54 self.report.status = 'finished'55 self.report.save()56def run(catalog_id):57 """58 :param catalog_id:59 :return: None60 """61 # it is the most complicated core logic function62 # so, get a couple of coffee63 print 'start running'64 catalog = Catalog.objects.get(pk=catalog_id)65 cases = get_catalog_cases(catalog)66 project = get_catalog_project(catalog)67 report = create_report(project, cases)68 print 'got '+str(len(cases))+' cases'69 for case in cases:70 skip = False71 path = get_case_path(case)72 variables = get_case_variables(case)73 operations = get_case_operations(case)74 repeat = case.repeat75 print 'start running a case'76 while repeat > 0:77 repeat -= 178 for operation in operations:79 if isinstance(operation, RequestOperation):80 request = Request(operation, variables)81 for result in request.excute(skip):82 print str(result)83 if operation.skip_next == 1 and not result["assert_result"] == "Pass":84 skip = True85 save_request_operation_log(report, path, result)86 if isinstance(operation, DBOperation):87 db = Database(operation,variables)88 for result in db.excute(skip):89 if operation.skip_next == 1 and not result["assert_result"] == "Pass":90 skip = True91 save_db_operation_log(report, path, result)92def get_catalog_cases(catalog):93 """94 :param: catalog95 :return: [case1,case2,case3...]96 """97 result = []98 def recur_catalog(catalog):99 if catalog.type == 'Case':100 result.append(catalog)101 children = Catalog.objects.all().filter(parent__id=catalog.id).exclude(type='Template').order_by('priority')102 for child in children:103 recur_catalog(child)104 recur_catalog(catalog)105 return result106def get_case_path(case):107 """108 :param case:109 :return:[catalog(case),catalog(module),catalog(project)]110 """111 result = []112 def recur_catalog_up(catalog):113 result.append(catalog)114 if not catalog.parent_id is None:115 parent = Catalog.objects.get(pk=catalog.parent.id)116 recur_catalog_up(parent)117 recur_catalog_up(case)118 return result119def get_catalog_project(catalog):120 """121 :param catalog:122 :return: project123 """124 return get_case_path(catalog)[-1]125def get_case_variables(case):126 """127 :param: case128 :return: [[variable1,variable2],[variable1],[variable1,variable2]]129 """130 result = []131 catalogs = get_case_path(case)132 for catalog in catalogs:133 result.append(Variable.objects.all().filter(catalog__id=catalog.id))134 return result135def get_case_operations(case):136 """137 :param case:138 :return: [request1,request2,db1,db2,request3,...] order by priority139 """...

Full Screen

Full Screen

Runner.py

Source:Runner.py Github

copy

Full Screen

...16# case_list = self.get_case_list(cases)17# print str(case_list)18# for case in case_list:19# skip_flag = False20# variables = self.get_case_variables(case['case_id'])21# catalog_names = self.get_case_parent_names(case['case_id'])22# for operation in case['operations']:23# operation_type = operation['type']24# operation_id = operation['id']25# operation_log = OperationLog()26# operation_log.task_id = task_id27# operation_log.type = operation_type28# operation_log.case_name = catalog_names[0]29# operation_log.module_name = catalog_names[1]30# operation_log.project_name = catalog_names[2]31#32# if operation_type == 'db':33# db_operation = DBOperation.objects.get(pk=operation_id)34# db = Database()35# db.excute(db_operation.sql)36# if operation_type == 'request':37# req_operation = RequestOperation.objects.get(pk=operation_id)38# request = Request(req_operation.header,req_operation.method,req_operation.url,req_operation.params,req_operation.body,variables,status=req_operation.expect_status,code=req_operation.test_code)39# result = request.request(skip_flag)40# print result41# operation_log.operation_info = result["operation_info"]42# operation_log.operation_result = result["operation_result"]43# operation_log.assert_result = result["assert_result"]44# operation_log.assert_info = result["assert_info"]45# operation_log.save()46# if req_operation.skip == 1 and not result["assert_result"] == "Pass":47# skip_flag = True48#49# def get_case_parent_names(self, case_id):50# """51# :param case_id:52# :return:[case_name,module_name,project_name]53# """54# result = []55# catalog = Catalog.objects.get(pk=case_id)56#57# def recur_parents(catalog):58# result.append(catalog.name)59# if not catalog.parent_id is None or catalog.parent_id == -1:60# parent = Catalog.objects.get(pk=catalog.parent.id)61# recur_parents(parent)62#63# recur_parents(catalog)64# return result65#66# def get_catalog_cases(self, catalog_id):67# """68# :param catalog_id:69# :return: [case_id1, case_id2]70# """71# result = []72# catalog = Catalog.objects.get(pk=catalog_id)73#74# def recur_sub_catalog(catalog):75# if catalog.type == 'Case':76# result.append(catalog)77#78# children = Catalog.objects.filter(parent_id=catalog.id).exclude(type='RequestTemplate').order_by('priority')79# if len(children) != 0:80# for child in children:81# recur_sub_catalog(child)82#83# recur_sub_catalog(catalog)84# return result85#86# def get_case_variables(self, case_id):87# """88# :param catalog_id:89# :return: [ {'key1':value1,'key2':value2,...},{}.... ] the first variables have the highest priority90# """91# result = []92# catalog = Catalog.objects.get(pk=case_id)93#94# def recur_parents(catalog):95# vars = Variable.objects.filter(catalog_id=catalog.id)96# var_dict = {}97# for var in vars:98# var_dict[var.key] = var.value99# result.append(var_dict)100# if not catalog.parent_id is None or catalog.parent_id == -1:...

Full Screen

Full Screen

cmmn.py

Source:cmmn.py Github

copy

Full Screen

...51 def get_case_instance_history(self, case_id):52 url = self.base_url + self._API_CMMN_GET_HISTORY_URL53 url = url.replace('{id}', case_id)54 return super().call('get', url, self.headers_json)55 def get_case_variables(self, case_id):56 url = self.base_url + self._API_CMMN_GET_VARIABLES_URL57 url = url.replace('{id}', case_id) + '?deserializeValues=false'58 59 return super().call('get', url, self.headers_json, self.headers_json)60 def update_case_variables(self, case_id, nome_variavel, valor, tipo):61 url = self.base_url + self._API_CMMN_UPDATE_VARIABLES_URL62 url = url.replace('{id}', case_id)63 url = url.replace('{varName}', nome_variavel)64 65 dados = {66 'value': valor,67 'type': tipo,68 }69 return super().call('put', url, self.headers_json, dados)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful