本文整理汇总了Python中driver.Driver.update_case_action_result方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.update_case_action_result方法的具体用法?Python Driver.update_case_action_result怎么用?Python Driver.update_case_action_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.update_case_action_result方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import update_case_action_result [as 别名]
#.........这里部分代码省略.........
self.environment = environment
self.driver.set_build_and_environment(build, environment)
self.no_run_id = False
self.conn = Connector(settings['database'])
def start_suite(self, name, attrs):
'''
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface-method-signatures
'''
doc = attrs['doc'] # doc is <type 'unicode'>
self.absolute_path = attrs['source']
tests = attrs['tests'] # empty suits return empty list
if tests: # empty list -> False any list other than empty list -> True
if not self.conn.is_exported_suite(self.absolute_path):
# This is the first time this suite is executed and,
plan_name = get_plan_name(self.absolute_path)
plan_id = None
if self.conn.is_exported_plan(plan_name):
# a plan is already created for the suites in this directory
plan_id = self.conn.get_PlanID(plan_name)
else:
# no plan has been created earlier that this suite belong to
# plans are not created for every new suite but for new suites
# with different top level directory
plan_id = self.driver.create_plan(plan_name)['plan_id']
self.conn.insert_plan_as_exported(plan_name, plan_id)
# For every new suite a Run will be created:
run = self.driver.create_run(plan_id, str(self.build), self.MANAGER, summary=str(doc))
self.run_id = run['run_id']
self.conn.insert_as_exported(self.absolute_path, self.run_id)
else:
# This is not a new suite and a Run already exist for it
self.run_id = self.conn.get_RunID(self.absolute_path)
def start_test(self, name, attrs):#todo: update doc string
'''case [Documentation] must start with "case_id;;"
'''
self.newCase = False
caselongname = attrs['longname'] #todo: should change to 'id', should work in new version of robot
if not self.conn.is_exported_case(caselongname, self.absolute_path):
# This case is newly added to the test suite or is the first time executed
self.newCase = True
self.actions = []
self.results = []
try:
summary = name + ' - ' + attrs['doc']
plan = self.driver.get_test_plan(self.run_id)
case = self.driver.create_case(priority='Normal', summary=summary, plans=plan,
tester=self.MANAGER)
self.case_id = case['case_id'] #todo: should case_id be class variable or local is ok?
self.driver.add_to_run(self.case_id, self.run_id)
self.conn.insert_case_as_exported(caselongname, self.absolute_path, self.case_id)
except:
print "Unexpected error in new TestCase processing:", sys.exc_info()[0]
raise
else:
self.case_id = self.conn.get_CaseID(caselongname, self.absolute_path)
self.driver.caserun_running(self.run_id, self.case_id)
def end_test(self, name, attrs):
status = attrs['status']
if status == 'PASS':
self.driver.caserun_passed(self.run_id, self.case_id)
elif status == 'FAIL':
self.driver.caserun_failed(self.run_id, self.case_id)
if self.newCase:
# Steps and results for new Case will be collected in a list by using start_keyword method
# list will be converted to a string with a html list format and inserted in Testopia
def make_html_list(elements):
'''
converts a list of "<li>...</li>" strings (i.e. collected list) to
a <ol><li>...</li>...</ol> string
'''
elements = ''.join(elements)
return '<ol>%s</ol>' % elements
action = make_html_list(self.actions)
result = make_html_list(self.results)
self.driver.update_case_action_result(self.case_id, action, result)
# clean up
self.case_id = None
def end_suite(self, name, attrs):
self.no_run_id = False
status = attrs['status']
message = attrs['message']
self.run_id = None
def start_keyword(self, name, attrs):
if self.newCase:
self.actions.append('<li>%s</li>' % name)
self.results.append('<li>%s</li>' % (attrs['doc'] or "No doc for keyword"))
def close(self):
self.conn.close()