本文整理汇总了Python中trac.ticket.Ticket.values['type']方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.values['type']方法的具体用法?Python Ticket.values['type']怎么用?Python Ticket.values['type']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.Ticket
的用法示例。
在下文中一共展示了Ticket.values['type']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateTracTickets
# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import values['type'] [as 别名]
def generateTracTickets( self, req ) :
"""
ok, it's a post so we know we are supposed to go ahead and create some TRAC tickets...the parameters that we care about are:
#users ...this will be a list...
#testtemplates ... this will be a list...
#testcases ... this will be a list...
#version...this will be a string...
#milestone...this will be a string...
This method does one of two things. It will either return: "True, URL" if ticket creation based on user input was succesful or "False, ErrorMessage" if
the ticket creation failed.
"""
#grab the parameters that we care about out of the request object
testRunDescription = str( req.args.get('testrundescription') )
users = req.args.get('users')
testTemplates = req.args.get('testtemplates')
testcases = req.args.get('testcases')
version = str( req.args.get('selectedversion'))
milestone = str( req.args.get('selectedmilestone'))
#-----------------------------------ERROR CHECKING ON PARAMETERS--------------------------------------------
if version == None:
version = ""
if milestone == None:
milestone = ""
if users == None :
return False, "No users selected for test run"
if isinstance( users, unicode):
users = [users.encode('ascii', 'ignore')]
version = version.encode('ascii', 'ignore').strip()
milestone = milestone.encode('ascii', 'ignore').strip()
if testcases == None :
testcases = [] #so we don't get a blow up later...
if testTemplates == None :
return False, "must select at least one testcase or test template to create a test run"
return 'errorCreatingTestRun.cs', None
elif testTemplates == None :
testTemplates = []
#create combined testcase list
testcases = self.createCombinedTestCaseList( testTemplates, testcases, req )
allTestcases = self.properties.getTestCases( self, req ) #fetch the testcases...
if allTestcases == None :
return False, None
#--------------------------------------------DONE ERROR CHECKING -----------------------------------------------
#ok this is where we actually create the tickets...
db = self.env.get_db_cnx()
for aUser in users :
for testId in testcases :
testId = testId.encode('ascii', 'ignore').strip()
if testId in allTestcases :
test = allTestcases[ testId ]
ticket = Ticket(self.env, db=db)
ticket.populate(req.args)
ticket.values['reporter'] = req.authname #the reporter is whoever is logged in
ticket.values['summary'] = "TestID: " + test.getId() + " -- " + test.getSummary()
ticket.values['description'] = "''''''Test Details:''''''\n\n" + test.getDescription() + "\n\n''''''Expected result:'''''' \n\n" + test.getExpectedResult()
ticket.values['type'] = 'testcase'
ticket.values['status'] = 'new'
ticket.values['action'] = 'create'
ticket.values['component'] = test.getComponent()
ticket.values['owner'] = aUser
ticket.values['version'] = version
ticket.values['milestone'] = milestone
ticket.values['keywords'] = "Test_ver" + version + "_mile_" + milestone
#self._validate_ticket(req, ticket) #probably should validate the ticket here.
ticket.insert(db=db)
db.commit()
else:
return False, "The test " + testId + " specified in a test template or as the testcaseID in the test file does not exist in the master test list "
#ok blow away the session vars incase someone trys to refresh the created test run page...no need to recreate all the tickets again...
#thanks to the haxs in the reporty.py module...
for var in ('users', 'testcases', 'testtemplates','milestone','version'):
if req.session.has_key(var):
del req.session[var]
#redirect to a custom query report showing the created tickets
return True, req.base_url + "/query?status=new&status=assigned&status=reopened&testcase_result=&version=" + version + "&milestone=" + milestone + "&type=testcase&order=priority&group=owner"
示例2: generateTracTickets
# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import values['type'] [as 别名]
#.........这里部分代码省略.........
if version == None:
version = ""
if milestone == None:
milestone = ""
if users == None :
return False, "No users selected for test run"
#check to see if the user, templates or testcases parameters is a str/unicode or a list (well if it isn't a unicode or str then it is a list)
if isinstance( users, unicode):
users = [users]
if isinstance( users, str):
users = [TracText.to_unicode ( users )]
if isinstance( testcases, unicode) :
testcases = [testcases]
if isinstance( testcases, str ):
testcases = [testcases]
if isinstance( testTemplates, unicode) :
testTemplates = [testTemplates]
if isinstance( testTemplates, str ):
testTemplates = [TracText.to_unicode ( testTemplates) ]
version = TracText.to_unicode ( version).strip()
milestone = TracText.to_unicode ( milestone ).strip()
if testcases == None :
testcases = [] #so we don't get a blow up later...
if testTemplates == None :
return False, "must select at least one testcase or test template to create a test run"
elif testTemplates == None :
testTemplates = []
#--------------------------------------------DONE ERROR CHECKING -----------------------------------------------
#create combined testcase list
testcases = self.createCombinedTestCaseList( testTemplates, testcases, req )
allTestcases, errors = self.properties.getTestCases( self, req ) #fetch the testcases...
if errors :
return False, errors
if allTestcases == None :
return False, None
#one last validation step
errorMessages = []
for aUser in users :
for testId in testcases :
testId = TracText.to_unicode( testId ).strip()
if testId in allTestcases :
continue
else:
self.env.log.info( "Testcase : " + testId + " not found in master list " )
errorMessages.append( "The test: " + testId + ", doesn't match it's file name or you've specified it wrong in the testtemplates.xml file" )
if errorMessages:
return False, errorMessages
#ok this is where we actually create the tickets...
db = self.env.get_db_cnx()
for aUser in users :
for testId in testcases :
testId = testId.encode('ascii', 'ignore').strip()
if testId in allTestcases :
test = allTestcases[ testId ]
ticket = Ticket(self.env, db=db)
ticket.populate(req.args)
ticket.values['reporter'] = req.authname #the reporter is whoever is logged in
ticket.values['summary'] = "TestID: " + test.getId() + " -- " + testConfiguration
ticket.values['description'] = "''''''Test Details:''''''\n\n" + test.getDescription() + "\n\n''''''Expected result:'''''' \n\n" + test.getExpectedResult()
ticket.values['type'] = 'testcase'
ticket.values['status'] = 'new'
ticket.values['action'] = 'create'
ticket.values['component'] = test.getComponent()
ticket.values['owner'] = aUser
ticket.values['version'] = version
ticket.values['milestone'] = milestone
ticket.values['keywords'] = testRunKeyWord
#self._validate_ticket(req, ticket) #probably should validate the ticket here.
ticket.insert(db=db)
db.commit()
else:
return False, "The test " + testId + " specified in a test template or as the testcaseID in the test file does not exist in the master test list "
#ok blow away the session vars incase someone trys to refresh the created test run page...no need to recreate all the tickets again...
#thanks to the haxs in the reporty.py module...
for var in ('users', 'testcases', 'testtemplates','milestone','version'):
if req.session.has_key(var):
del req.session[var]
#redirect to a custom query report showing the created tickets
return True, req.base_url + "/query?status=new&status=assigned&status=reopened&status=accepted&testcase_result=&version=" + version + "&milestone=" + milestone + "&type=testcase&order=priority&group=owner"