[Buildbot-commits] buildbot/buildbot/test test_web.py,1.19,1.20

Brian Warner warner at users.sourceforge.net
Tue Jul 19 23:51:55 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26774/buildbot/test

Modified Files:
	test_web.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-244
Creator:  Brian Warner <warner at lothar.com>

remove deferredResult from test_web.py

	* buildbot/test/test_web.py (WebTest): remove use of deferredResult,
	bring it properly up to date with twisted-2.0 test guidelines


Index: test_web.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_web.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test_web.py	19 Jul 2005 23:11:59 -0000	1.19
+++ test_web.py	19 Jul 2005 23:51:52 -0000	1.20
@@ -5,14 +5,13 @@
 #log.startLogging(sys.stderr)
 
 from twisted.trial import unittest
-dr = unittest.deferredResult
 
 from twisted.internet import reactor, defer
 from twisted.internet.interfaces import IReactorUNIX
 from twisted.web import client
 
 from buildbot import master, interfaces, buildset, sourcestamp
-from buildbot.twcompat import providedBy
+from buildbot.twcompat import providedBy, maybeWait
 from buildbot.status import html, builder
 from buildbot.changes.changes import Change
 from buildbot.process import step, base
@@ -88,7 +87,7 @@
         http._logDateTimeStop()
         if self.master:
             d = self.master.stopService()
-            dr(d)
+            return maybeWait(d)
 
     def find_waterfall(self, master):
         return filter(lambda child: isinstance(child, html.Waterfall),
@@ -104,7 +103,10 @@
         port = list(self.find_waterfall(m)[0])[0]._port.getHost().port
 
         d = client.getPage("http://localhost:%d/" % port)
-        page = dr(d, 10)
+        d.addCallback(self._test_webPortnum_1)
+        return maybeWait(d)
+    test_webPortnum.timeout = 10
+    def _test_webPortnum_1(self, page):
         #print page
         self.failUnless(page)
 
@@ -121,11 +123,14 @@
         p = DistribUNIX("test_web2/.web-pb")
 
         d = client.getPage("http://localhost:%d/remote/" % p.portnum)
-        page = dr(d, 10)
+        d.addCallback(self._test_webPathname_1, p)
+        return maybeWait(d)
+    test_webPathname.timeout = 10
+    def _test_webPathname_1(self, page, p):
         #print page
         self.failUnless(page)
-        dr(p.shutdown())
-        
+        return p.shutdown()
+
 
     def test_webPathname_port(self):
         # running a t.web.distrib server over TCP
@@ -139,9 +144,12 @@
         p = DistribTCP(dport)
 
         d = client.getPage("http://localhost:%d/remote/" % p.portnum)
-        page = dr(d, 10)
+        d.addCallback(self._test_webPathname_port_1, p)
+        return maybeWait(d)
+    test_webPathname_port.timeout = 10
+    def _test_webPathname_port_1(self, page, p):
         self.failUnlessIn("BuildBot", page)
-        dr(p.shutdown())
+        return p.shutdown()
 
     def test_waterfall(self):
         # this is the right way to configure the Waterfall status
@@ -160,7 +168,10 @@
         m.change_svc.addChange(Change("user", ["foo.c"], "comments"))
 
         d = client.getPage("http://localhost:%d/" % port)
-        page = dr(d)
+        d.addCallback(self._test_waterfall_1, port)
+        return maybeWait(d)
+    test_waterfall.timeout = 10
+    def _test_waterfall_1(self, page, port):
         self.failUnless(page)
         self.failUnlessIn("current activity", page)
         self.failUnlessIn("<html>", page)
@@ -169,17 +180,23 @@
 
         # phase=0 is really for debugging the waterfall layout
         d = client.getPage("http://localhost:%d/?phase=0" % port)
-        page = dr(d)
+        d.addCallback(self._test_waterfall_2, port)
+        return d
+    def _test_waterfall_2(self, page, port):
         self.failUnless(page)
         self.failUnlessIn("<html>", page)
 
         d = client.getPage("http://localhost:%d/favicon.ico" % port)
-        icon = dr(d)
+        d.addCallback(self._test_waterfall_3, port)
+        return d
+    def _test_waterfall_3(self, icon, port):
         expected = open(html.buildbot_icon,"rb").read()
         self.failUnless(icon == expected)
 
         d = client.getPage("http://localhost:%d/changes" % port)
-        changes = dr(d)
+        d.addCallback(self._test_waterfall_4)
+        return d
+    def _test_waterfall_4(self, changes):
         self.failUnlessIn("<li>Syncmail mailing list in maildir " +
                           "my-maildir</li>", changes)
 
@@ -225,19 +242,29 @@
         bs.buildFinished()
 
         d = client.getPage("http://localhost:%d/" % port)
-        page = dr(d, 5)
+        d.addCallback(self._test_logfile_1, port)
+        return maybeWait(d)
+    test_logfile.timeout = 10
+    def _test_logfile_1(self, page, port):
         self.failUnless(page)
 
         logurl = "http://localhost:%d/builder1/builds/0/setup/0" % port
         d = client.getPage(logurl)
-        logbody = dr(d, 5)
+        d.addCallback(self._test_logfile_2, port)
+        return d
+    def _test_logfile_2(self, logbody, port):
         self.failUnless(logbody)
+        logurl = "http://localhost:%d/builder1/builds/0/setup/0" % port
         d = client.getPage(logurl + "/text")
-        logtext = dr(d, 5)
+        d.addCallback(self._test_logfile_3, port)
+        return d
+    def _test_logfile_3(self, logtext, port):
         self.failUnlessEqual(logtext, "some stdout\n")
 
         logurl = "http://localhost:%d/builder1/builds/0/setup/1" % port
         d = client.getPage(logurl)
-        logbody = dr(d, 5)
+        d.addCallback(self._test_logfile_4)
+        return d
+    def _test_logfile_4(self, logbody):
         self.failUnlessEqual(logbody, "<html>ouch</html>")
 





More information about the Commits mailing list