Skip to content

Commit

Permalink
make fake and real addBuildsetFor.. methods match
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Aug 22, 2013
1 parent d26b8c9 commit 99f81a0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -146,6 +146,10 @@ For each resource type, we'll need the following (based on "Adding Resource Type
* Steps' URLs should be stored as JSON objects giving both a title and a URL. :runner:
* Validate messages using the same system as used to validate resource types

## Testing ##

The BaseScheduler's addBuildsetForXxx methods should have their signatures checked against the corresponding fakes.

## Status Rewrites ##

The following will need to be rewritten:
Expand Down
12 changes: 7 additions & 5 deletions master/buildbot/schedulers/base.py
Expand Up @@ -175,7 +175,7 @@ def gotChange(self, change, important):
## starting bulids

def addBuildsetForSourceStampsWithDefaults(self, reason, sourcestamps,
waited_for, properties=None, builderNames=None):
waited_for=False, properties=None, builderNames=None):

if sourcestamps is None:
sourcestamps = []
Expand Down Expand Up @@ -208,8 +208,9 @@ def getCodebaseDict(self, codebase):
return self.codebases[codebase]

@defer.inlineCallbacks
def addBuildsetForChanges(self, waited_for, reason='', external_idstring=None,
changeids=[], builderNames=None, properties=None):
def addBuildsetForChanges(self, waited_for=False, reason='',
external_idstring=None, changeids=[], builderNames=None,
properties=None):
changesByCodebase = {}

def get_last_change_for_codebase(codebase):
Expand Down Expand Up @@ -246,8 +247,9 @@ def get_last_change_for_codebase(codebase):

defer.returnValue((bsid,brids))

def addBuildsetForSourceStamps(self, waited_for, sourcestamps=[], reason='',
external_idstring=None, properties=None, builderNames=None):
def addBuildsetForSourceStamps(self, waited_for=False, sourcestamps=[],
reason='', external_idstring=None, properties=None,
builderNames=None):
# combine properties
if properties:
properties.updateFromProperties(self.properties)
Expand Down
5 changes: 5 additions & 0 deletions master/buildbot/test/unit/test_schedulers_forcesched.py
Expand Up @@ -126,6 +126,7 @@ def test_basicForce(self):
self.assertEqual(self.addBuildsetCalls, [
('addBuildsetForSourceStampsWithDefaults', dict(
builderNames=['a'],
waited_for=False,
properties={
u'owner': ('user', u'Force Build Form'),
u'p1': ('e', u'Force Build Form'),
Expand All @@ -152,6 +153,7 @@ def test_force_allBuilders(self):
self.assertEqual(self.addBuildsetCalls, [
('addBuildsetForSourceStampsWithDefaults', dict(
builderNames=['a', 'b'],
waited_for=False,
properties={
u'owner': ('user', u'Force Build Form'),
u'reason': ('because', u'Force Build Form'),
Expand All @@ -175,6 +177,7 @@ def test_force_someBuilders(self):
self.assertEqual(self.addBuildsetCalls, [
('addBuildsetForSourceStampsWithDefaults', dict(
builderNames=['a', 'b'],
waited_for=False,
properties={
u'owner': ('user', u'Force Build Form'),
u'reason': ('because', u'Force Build Form'),
Expand Down Expand Up @@ -239,6 +242,7 @@ def test_good_codebases(self):
self.assertEqual(self.addBuildsetCalls, [
('addBuildsetForSourceStampsWithDefaults', dict(
builderNames=['a'],
waited_for=False,
properties=expProperties,
reason=u"A build was forced by 'user': because",
sourcestamps=[
Expand Down Expand Up @@ -305,6 +309,7 @@ def do_ParameterTest(self,
self.assertEqual(self.addBuildsetCalls, [
('addBuildsetForSourceStampsWithDefaults', dict(
builderNames=['a'],
waited_for=False,
properties=expect_props,
reason=u"A build was forced by 'user': because",
sourcestamps=[
Expand Down
Expand Up @@ -49,7 +49,8 @@ def assertBuildsetAdded(self, sourcestamps={}, properties={}):
properties=properties,
reason=u"The NightlyTriggerable scheduler named 'test' "
u"triggered this build",
sourcestamps=sourcestamps)),
sourcestamps=sourcestamps,
waited_for=False)),
])
self.addBuildsetCalls = []

Expand Down
9 changes: 5 additions & 4 deletions master/buildbot/test/util/scheduler.py
Expand Up @@ -168,7 +168,7 @@ def _addBuildsetReturnValue(self, builderNames):
return defer.succeed((bsid, brids))

def fake_addBuildsetForSourceStampsWithDefaults(self, reason, sourcestamps,
properties=None, builderNames=None):
waited_for=False, properties=None, builderNames=None):
properties = properties.asDict()
self.assertIsInstance(sourcestamps, list)
sourcestamps.sort()
Expand All @@ -177,15 +177,16 @@ def fake_addBuildsetForSourceStampsWithDefaults(self, reason, sourcestamps,
self.addBuildsetCalls[-1][1].pop('self')
return self._addBuildsetReturnValue(builderNames)

def fake_addBuildsetForChanges(self, reason='', external_idstring=None,
def fake_addBuildsetForChanges(self, waited_for=False, reason='', external_idstring=None,
changeids=[], builderNames=None, properties=None):
properties = properties.asDict() if properties is not None else None
self.addBuildsetCalls.append(('addBuildsetForChanges', locals()))
self.addBuildsetCalls[-1][1].pop('self')
return self._addBuildsetReturnValue(builderNames)

def fake_addBuildsetForSourceStamps(self, sourcestamps=[], reason='',
external_idstring=None, properties=None, builderNames=None):
def fake_addBuildsetForSourceStamps(self, waited_for=False, sourcestamps=[],
reason='', external_idstring=None, properties=None,
builderNames=None):
properties=properties.asDict() if properties is not None else None
self.assertIsInstance(sourcestamps, list)
sourcestamps.sort()
Expand Down

0 comments on commit 99f81a0

Please sign in to comment.