Package buildbot :: Package status :: Package web :: Module tests
[frames] | no frames]

Source Code for Module buildbot.status.web.tests

 1   
 2  import urllib 
 3  from buildbot.status.web.base import HtmlResource, path_to_builder, \ 
 4       path_to_build, css_classes 
 5  from buildbot.status.web.logs import LogsResource 
 6  from buildbot.status.builder import Results 
 7  from buildbot import util 
 8  from time import ctime 
 9   
10  # /builders/$builder/builds/$buildnum/steps/$stepname 
11 -class StatusResourceBuildTest(HtmlResource):
12 title = "Test Result" 13 addSlash = True 14
15 - def __init__(self, build_status, test_result):
16 HtmlResource.__init__(self) 17 self.status = build_status 18 self.test_result = test_result
19
20 - def content(self, req, cxt):
21 tr = self.test_result 22 b = self.status 23 24 cxt['b'] = self.status 25 logs = cxt['logs'] = [] 26 for lname, log in tr.getLogs().items(): 27 if isinstance(log, str): 28 log = log.decode('utf-8') 29 logs.append({'name': lname, 30 'log': log, 31 'link': req.childLink("logs/%s" % urllib.quote(lname)) }) 32 33 cxt['text'] = tr.text 34 cxt['result_word'] = Results[tr.getResults()] 35 cxt.update(dict(builder_link = path_to_builder(req, b.getBuilder()), 36 build_link = path_to_build(req, b), 37 result_css = css_classes[tr.getResults()], 38 b = b, 39 tr = tr)) 40 41 template = req.site.buildbot_service.templates.get_template("testresult.html") 42 return template.render(**cxt)
43
44 - def getChild(self, path, req):
45 # if path == "logs": 46 # return LogsResource(self.step_status) #TODO we need another class 47 return HtmlResource.getChild(self, path, req)
48 49 50 51 # /builders/$builder/builds/$buildnum/steps
52 -class TestsResource(HtmlResource):
53 addSlash = True 54 nameDelim = '.' # Test result have names like a.b.c 55
56 - def __init__(self, build_status):
59
60 - def content(self, req, ctx):
61 # TODO list the tests 62 return "subpages show data for each test"
63
64 - def getChild(self, path, req):
65 tpath = None 66 if path: 67 tpath = tuple(path.split(self.nameDelim)) 68 if tpath: 69 tr = self.build_status.getTestResults().get(tpath) 70 if tr: 71 return StatusResourceBuildTest(self.build_status, tr) 72 return HtmlResource.getChild(self, path, req)
73