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

Source Code for Module buildbot.status.web.tests

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16   
17  import urllib 
18  from buildbot.status.web.base import HtmlResource, path_to_builder, \ 
19       path_to_build, css_classes 
20  from buildbot.status.builder import Results 
21   
22  # /builders/$builder/builds/$buildnum/steps/$stepname 
23 -class StatusResourceBuildTest(HtmlResource):
24 pageTitle = "Test Result" 25 addSlash = True 26
27 - def __init__(self, build_status, test_result):
28 HtmlResource.__init__(self) 29 self.status = build_status 30 self.test_result = test_result
31
32 - def content(self, req, cxt):
33 tr = self.test_result 34 b = self.status 35 36 cxt['b'] = self.status 37 logs = cxt['logs'] = [] 38 for lname, log in tr.getLogs().items(): 39 if isinstance(log, str): 40 log = log.decode('utf-8') 41 logs.append({'name': lname, 42 'log': log, 43 'link': req.childLink("logs/%s" % urllib.quote(lname)) }) 44 45 cxt['text'] = tr.text 46 cxt['result_word'] = Results[tr.getResults()] 47 cxt.update(dict(builder_link = path_to_builder(req, b.getBuilder()), 48 build_link = path_to_build(req, b), 49 result_css = css_classes[tr.getResults()], 50 b = b, 51 tr = tr)) 52 53 template = req.site.buildbot_service.templates.get_template("testresult.html") 54 return template.render(**cxt)
55
56 - def getChild(self, path, req):
57 # if path == "logs": 58 # return LogsResource(self.step_status) #TODO we need another class 59 return HtmlResource.getChild(self, path, req)
60 61 62 63 # /builders/$builder/builds/$buildnum/steps
64 -class TestsResource(HtmlResource):
65 addSlash = True 66 nameDelim = '.' # Test result have names like a.b.c 67
68 - def __init__(self, build_status):
71
72 - def content(self, req, ctx):
73 # TODO list the tests 74 return "subpages show data for each test"
75
76 - def getChild(self, path, req):
77 tpath = None 78 if path: 79 tpath = tuple(path.split(self.nameDelim)) 80 if tpath: 81 tr = self.build_status.getTestResults().get(tpath) 82 if tr: 83 return StatusResourceBuildTest(self.build_status, tr) 84 return HtmlResource.getChild(self, path, req)
85