[Buildbot-commits] buildbot/buildbot/test test_web.py,1.21,1.22
Brian Warner
warner at users.sourceforge.net
Sun Oct 16 06:25:36 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3074/buildbot/test
Modified Files:
test_web.py
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-334
Creator: Brian Warner <warner at lothar.com>
add getURLForThing status method
* buildbot/status/builder.py (Status.getURLForThing): add method
to provide a URL for arbitrary IStatusFoo objects. The idea is to
use this in email/IRC status clients to make them more useful, by
providing the end user with hints on where to learn more about the
object being reported on.
* buildbot/test/test_web.py (GetURL): tests for it
Index: test_web.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_web.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- test_web.py 9 Aug 2005 00:43:35 -0000 1.21
+++ test_web.py 16 Oct 2005 06:25:34 -0000 1.22
@@ -5,6 +5,7 @@
#log.startLogging(sys.stderr)
from twisted.trial import unittest
+from buildbot.test.runutils import RunMixin
from twisted.internet import reactor, defer, protocol
from twisted.internet.interfaces import IReactorUNIX
@@ -99,6 +100,14 @@
self.p.factory = self
return self.p
+def stopHTTPLog():
+ # grr.
+ try:
+ from twisted.web import http # Twisted-2.0
+ except ImportError:
+ from twisted.protocols import http # Twisted-1.3
+ http._logDateTimeStop()
+
class BaseWeb:
master = None
@@ -106,12 +115,7 @@
self.failUnless(string.find(substr) != -1)
def tearDown(self):
- # grr.
- try:
- from twisted.web import http # Twisted-2.0
- except ImportError:
- from twisted.protocols import http # Twisted-1.3
- http._logDateTimeStop()
+ stopHTTPLog()
if self.master:
d = self.master.stopService()
return maybeWait(d)
@@ -231,7 +235,119 @@
self.failUnlessIn("<li>Syncmail mailing list in maildir " +
"my-maildir</li>", changes)
-class Logfile(BaseWeb, unittest.TestCase):
+
+geturl_config = """
+from buildbot.status import html
+from buildbot.changes import mail
+from buildbot.process import step, factory
+from buildbot.scheduler import Scheduler
+from buildbot.changes.base import ChangeSource
+s = factory.s
+
+class DiscardScheduler(Scheduler):
+ def addChange(self, change):
+ pass
+class DummyChangeSource(ChangeSource):
+ pass
+
+BuildmasterConfig = c = {}
+c['bots'] = [('bot1', 'sekrit'), ('bot2', 'sekrit')]
+c['sources'] = [DummyChangeSource()]
+c['schedulers'] = [DiscardScheduler('discard', None, 60, ['b1'])]
+c['slavePortnum'] = 0
+c['status'] = [html.Waterfall(http_port=0)]
+
+f = factory.BuildFactory([s(step.RemoteDummy, timeout=1)])
+
+c['builders'] = [
+ {'name': 'b1', 'slavenames': ['bot1','bot2'],
+ 'builddir': 'b1', 'factory': f},
+ ]
+c['buildbotURL'] = 'http://dummy.example.org:8010/'
+
+"""
+
+class GetURL(RunMixin, unittest.TestCase):
+
+ def setUp(self):
+ RunMixin.setUp(self)
+ self.master.loadConfig(geturl_config)
+ self.master.startService()
+ d = self.connectSlave(["b1"])
+ return maybeWait(d)
+
+ def tearDown(self):
+ stopHTTPLog()
+ return RunMixin.tearDown(self)
+
+ def doBuild(self, buildername):
+ br = base.BuildRequest("forced", sourcestamp.SourceStamp())
+ d = self.control.getBuilder(buildername).requestBuild(br)
+ return d
+
+ def assertNoURL(self, target):
+ self.failUnlessIdentical(self.status.getURLForThing(target), None)
+
+ def assertURLEqual(self, target, expected):
+ got = self.status.getURLForThing(target)
+ full_expected = "http://dummy.example.org:8010/" + expected
+ self.failUnlessEqual(got, full_expected)
+
+ def testMissingBase(self):
+ noweb_config1 = geturl_config + "del c['buildbotURL']\n"
+ d = self.master.loadConfig(noweb_config1)
+ d.addCallback(self._testMissingBase_1)
+ return maybeWait(d)
+ def _testMissingBase_1(self, res):
+ s = self.status
+ self.assertNoURL(s)
+ builder = s.getBuilder("b1")
+ self.assertNoURL(builder)
+
+ def testBase(self):
+ s = self.status
+ self.assertURLEqual(s, "")
+ builder = s.getBuilder("b1")
+ self.assertURLEqual(builder, "b1")
+
+ def testBrokenStuff(self):
+ s = self.status
+ self.assertURLEqual(s.getSchedulers()[0], "schedulers/0")
+ self.assertURLEqual(s.getSlave("bot1"), "slaves/bot1")
+ # we didn't put a Change into the actual Build before, so this fails
+ #self.assertURLEqual(build.getChanges()[0], "changes/1")
+ testBrokenStuff.todo = "not implemented yet"
+
+ def testChange(self):
+ s = self.status
+ c = Change("user", ["foo.c"], "comments")
+ self.master.change_svc.addChange(c)
+ # TODO: something more like s.getChanges(), requires IChange and
+ # an accessor in IStatus. The HTML page exists already, though
+ self.assertURLEqual(c, "changes/1")
+
+ def testBuild(self):
+ # first we do some stuff so we'll have things to look at.
+ s = self.status
+ d = self.doBuild("b1")
+ # maybe check IBuildSetStatus here?
+ d.addCallback(self._testBuild_1)
+ return maybeWait(d)
+
+ def _testBuild_1(self, res):
+ s = self.status
+ builder = s.getBuilder("b1")
+ build = builder.getLastFinishedBuild()
+ self.assertURLEqual(build, "b1/builds/0")
+ # no page for builder.getEvent(-1)
+ step = build.getSteps()[0]
+ self.assertURLEqual(step, "b1/builds/0/remote dummy") # really?
+ # maybe page for build.getTestResults?
+ self.assertURLEqual(step.getLogs()[0], "b1/builds/0/remote dummy/0")
+
+
+
+class Logfile(BaseWeb, RunMixin, unittest.TestCase):
def setUp(self):
config = """
from buildbot.status import html
More information about the Commits
mailing list