|
OLD | NEW |
---|---|
(Empty) | |
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 import os | |
17 from mock import Mock | |
18 from twisted.trial import unittest | |
19 from buildbot.status import builder, master | |
20 | |
21 class TestBuildStatus(unittest.TestCase): | |
22 | |
23 # that buildstep.BuildStepStatus is never instantiated here should tell you | |
24 # that these classes are not well isolated! | |
25 | |
26 def setupBuilder(self, buildername, category=None): | |
27 b = builder.BuilderStatus(buildername=buildername, category=category) | |
28 # Ackwardly, Status sets this member variable. | |
cmp
2012/03/16 21:57:08
Ackwardly -> Awkwardly
szager
2012/03/16 22:02:24
Done.
| |
29 b.basedir = os.path.abspath(self.mktemp()) | |
30 os.mkdir(b.basedir) | |
31 # Otherwise, builder.nextBuildNumber is not defined. | |
32 b.determineNextBuildNumber() | |
33 # Must initialize these fields before pickling. | |
34 b.currentBigState = 'idle' | |
35 b.status = 'idle' | |
36 return b | |
37 | |
38 def setupStatus(self, b): | |
39 m = Mock() | |
40 m.buildbotURL = 'http://buildbot:8010/' | |
41 m.basedir = '/basedir' | |
42 s = master.Status(m) | |
43 b.status = s | |
44 return s | |
45 | |
46 def testBuildCache(self): | |
47 b = self.setupBuilder('builder_1') | |
48 builds = [] | |
49 for i in xrange(5): | |
50 build = b.newBuild() | |
51 build.setProperty('propkey', 'propval%d' % i, 'test') | |
52 builds.append(build) | |
53 build.buildStarted(build) | |
54 build.buildFinished() | |
55 for build in builds: | |
56 build2 = b.getBuild(build.number) | |
57 self.assertTrue(build2) | |
58 self.assertEqual(build2.number, build.number) | |
59 self.assertEqual(build.getProperty('propkey'), | |
60 'propval%d' % build.number) | |
cmp
2012/03/16 21:57:08
can you add a test to verify that the cache's hits
szager
2012/03/16 22:02:24
Done.
| |
OLD | NEW |