[Buildbot-commits] buildbot/buildbot/test test_status.py, 1.46, 1.47

Brian Warner warner at users.sourceforge.net
Mon Jul 21 14:52:26 UTC 2008


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

Modified Files:
	test_status.py 
Log Message:
[project @ #228:step-statistics.patch]
Introduce steps statistics

Original author: dustin at v.igoro.us
Date: 2008-06-26 03:30:36+00:00

Index: test_status.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_status.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- test_status.py	26 May 2008 23:52:18 -0000	1.46
+++ test_status.py	21 Jul 2008 14:52:24 -0000	1.47
@@ -1,6 +1,7 @@
 # -*- test-case-name: buildbot.test.test_status -*-
 
 import email, os
+import operator
 
 from zope.interface import implements
 from twisted.internet import defer, reactor
@@ -1194,3 +1195,36 @@
 
     def send(self, msg):
         self.message += msg
+
+class StepStatistics(unittest.TestCase):
+    def testStepStatistics(self):
+        status = builder.BuildStatus(builder.BuilderStatus("test"), 123)
+        status.addStepWithName('step1')
+        status.addStepWithName('step2')
+        status.addStepWithName('step3')
+        status.addStepWithName('step4')
+
+        steps = status.getSteps()
+        (step1, step2, step3, step4) = steps
+
+        step1.setStatistic('test-prop', 1)
+        step3.setStatistic('test-prop', 2)
+        step4.setStatistic('test-prop', 4)
+
+        step1.setStatistic('other-prop', 27)
+        # Just to have some other properties around
+
+        self.failUnlessEqual(step1.getStatistic('test-prop'), 1,
+            'Retrieve an existing property')
+        self.failUnlessEqual(step1.getStatistic('test-prop', 99), 1,
+            "Don't default an existing property")
+        self.failUnlessEqual(step2.getStatistic('test-prop', 99), 99,
+            'Default a non-existant property')
+
+        self.failUnlessEqual(
+            status.getSummaryStatistic('test-prop', operator.add), 7,
+            'Sum property across the build')
+
+        self.failUnlessEqual(
+            status.getSummaryStatistic('test-prop', operator.add, 13), 20,
+            'Sum property across the build with initial value')





More information about the Commits mailing list