本文整理汇总了Python中buildbot.test.fake.fakebuild.FakeBuildStatus.finished方法的典型用法代码示例。如果您正苦于以下问题:Python FakeBuildStatus.finished方法的具体用法?Python FakeBuildStatus.finished怎么用?Python FakeBuildStatus.finished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buildbot.test.fake.fakebuild.FakeBuildStatus
的用法示例。
在下文中一共展示了FakeBuildStatus.finished方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_buildsetComplete_sends_email
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_buildsetComplete_sends_email(self):
fakeBuildMessage = Mock()
mn = MailNotifier('[email protected]',
buildSetSummary=True,
mode=("failing", "passing", "warnings"),
builders=["Builder1", "Builder2"])
mn.buildMessage = fakeBuildMessage
builder1 = Mock()
builder1.getBuild = lambda number: build1
builder1.name = "Builder1"
build1 = FakeBuildStatus()
build1.results = FAILURE
build1.finished = True
build1.reason = "testReason"
build1.getBuilder.return_value = builder1
build1.getResults.return_value = build1.results
builder2 = Mock()
builder2.getBuild = lambda number: build2
builder2.name = "Builder2"
build2 = FakeBuildStatus()
build2.results = FAILURE
build2.finished = True
build2.reason = "testReason"
build2.getBuilder.return_value = builder1
build2.getResults.return_value = build2.results
def fakeGetBuilder(buildername):
return {"Builder1": builder1, "Builder2": builder2}[buildername]
self.db = fakedb.FakeDBConnector(self)
self.db.insertTestData([fakedb.SourceStampSet(id=127),
fakedb.Buildset(id=99, sourcestampsetid=127,
results=SUCCESS,
reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99,
buildername='Builder1'),
fakedb.Build(number=0, brid=11),
fakedb.BuildRequest(id=12, buildsetid=99,
buildername='Builder2'),
fakedb.Build(number=0, brid=12),
])
mn.master = self # FIXME: Should be FakeMaster
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict = Mock()
mn.buildMessageDict.return_value = {"body": "body", "type": "text",
"subject": "subject"}
mn._buildsetComplete(99, FAILURE)
fakeBuildMessage.assert_called_with("(whole buildset)",
[build1, build2], SUCCESS)
示例2: run_fake_summary_build
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def run_fake_summary_build(self, gsp, buildResults, finalResult,
resultText):
buildpairs = []
i = 0
for i in xrange(len(buildResults)):
buildResult = buildResults[i]
builder = Mock()
build = FakeBuildStatus()
builder.getBuild.return_value = build
builder.name = "Builder-%d" % i
builder.getName.return_value = builder.name
build.results = buildResult
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
build.getResults.return_value = build.results
build.getText.return_value = ['buildText']
build.getProperty = self.TEST_PROPS.get
buildpairs.append((builder, build))
def fakeGetBuilder(buildername):
# e.g. Builder-5 will be buildpairs[5][0]
return buildpairs[int(buildername.split("-")[1])][0]
gsp.master_status.getBuilder = fakeGetBuilder
gsp.master_status.getURLForThing = Mock()
gsp.master_status.getURLForThing.return_value = self.THING_URL
gsp.master.db = fakedb.FakeDBConnector(self)
fakedata = [
fakedb.SourceStampSet(id=127),
fakedb.Buildset(id=99, sourcestampsetid=127, results=finalResult, reason="testReason")
]
breqid = 1000
for (builder, build) in buildpairs:
fakedata.append(fakedb.BuildRequest(id=breqid, buildsetid=99,
buildername=builder.name))
fakedata.append(fakedb.Build(number=0, brid=breqid))
breqid = breqid + 1
gsp.master.db.insertTestData(fakedata)
d = gsp._buildsetComplete(99, finalResult)
@d.addCallback
def check(_):
info = []
for i in xrange(len(buildResults)):
info.append({'name': "Builder-%d" % i, 'result': buildResults[i],
'resultText': resultText[i], 'text': 'buildText',
'url': self.THING_URL})
return str(info)
return d
示例3: test_buildsetComplete_doesnt_send_email
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_buildsetComplete_doesnt_send_email(self):
fakeBuildMessage = Mock()
mn = MailNotifier('[email protected]',
buildSetSummary=True,
mode=("failing", "warnings"),
builders=["Builder"])
mn.buildMessage = fakeBuildMessage
def fakeGetBuild(number):
return build
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername": "Builder", "brid": 1}])
builder = Mock()
builder.getBuild = fakeGetBuild
builder.name = "Builder"
build = FakeBuildStatus()
build.results = SUCCESS
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
build.getResults.return_value = build.results
self.db = self.master.db
self.db.insertTestData([
fakedb.Master(id=92),
fakedb.Buildslave(id=13, name='sl'),
fakedb.Buildset(id=99, results=SUCCESS, reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99, buildername='Builder'),
fakedb.Build(number=0, buildrequestid=11, buildslaveid=13,
masterid=92),
])
mn.master = self.master
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict = Mock()
mn.buildMessageDict.return_value = {"body": "body", "type": "text",
"subject": "subject"}
d = mn._buildsetComplete('buildset.99.complete',
dict(bsid=99, result=FAILURE))
@d.addCallback
def check(_):
self.assertFalse(fakeBuildMessage.called)
return d
示例4: test_buildsetFinished_sends_email
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_buildsetFinished_sends_email(self):
fakeBuildMessage = Mock()
mn = MailNotifier('[email protected]',
buildSetSummary=True,
mode=("failing", "passing", "warnings"),
builders=["Builder"])
mn.buildMessage = fakeBuildMessage
def fakeGetBuild(number):
return build
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername":"Builder", "brid":1}])
builder = Mock()
builder.getBuild = fakeGetBuild
builder.name = "Builder"
build = FakeBuildStatus()
build.results = FAILURE
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
self.db = fakedb.FakeDBConnector(self)
self.db.insertTestData([fakedb.SourceStampSet(id=127),
fakedb.Buildset(id=99, sourcestampsetid=127,
results=SUCCESS,
reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99,
buildername='Builder'),
fakedb.Build(number=0, brid=11),
])
mn.master = self # FIXME: Should be FakeMaster
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict = Mock()
mn.buildMessageDict.return_value = {"body":"body", "type":"text",
"subject":"subject"}
mn.buildsetFinished(99, FAILURE)
fakeBuildMessage.assert_called_with("Buildset Complete: testReason",
[build], SUCCESS)
示例5: run_fake_build
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def run_fake_build(self, notifier, info=None):
notifier.master = fakemaster.make_master()
notifier.master_status = notifier.master.status
builders = []
builds = []
for i in [0, 1, 2]:
builder = Mock()
build = FakeBuildStatus()
builder.getBuild.return_value = build
builder.name = "Builder%d" % i
build.results = SUCCESS
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
builders.append(builder)
builds.append(build)
def fakeGetBuilder(buildername):
return {"Builder0": builders[0], "Builder1": builders[1], "Builder2": builders[2]}[buildername]
notifier.master_status.getBuilder = fakeGetBuilder
notifier.master.db = fakedb.FakeDBConnector(notifier.master, self)
notifier.master.db.insertTestData([
fakedb.Master(id=92),
fakedb.Buildslave(id=13, name='sl'),
fakedb.Buildset(id=99, results=SUCCESS, reason="testReason"),
fakedb.Builder(id=80, name='Builder0'),
fakedb.Builder(id=81, name='Builder1'),
fakedb.Builder(id=82, name='Builder2'),
fakedb.BuildRequest(id=10, buildsetid=99, builderid=80),
fakedb.Build(number=0, buildrequestid=10, masterid=92, buildslaveid=13),
fakedb.BuildRequest(id=11, buildsetid=99, builderid=81),
fakedb.Build(number=0, buildrequestid=11, masterid=92, buildslaveid=13),
fakedb.BuildRequest(id=12, buildsetid=99, builderid=82),
fakedb.Build(number=0, buildrequestid=12, masterid=92, buildslaveid=13)
])
if info is not None:
info['bsid'] = 99
info['builds'] = builds
d = notifier._buildsetComplete('buildset.99.complete',
{'bsid': 99, 'result': SUCCESS})
return d
示例6: run_fake_build
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def run_fake_build(self, notifier, info=None):
notifier.master = fakemaster.make_master()
notifier.master_status = notifier.master.status
builders = []
builds = []
for i in [0, 1, 2]:
builder = Mock()
build = FakeBuildStatus()
builder.getBuild.return_value = build
builder.name = "Builder%d" % i
build.results = SUCCESS
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
builders.append(builder)
builds.append(build)
def fakeGetBuilder(buildername):
return {"Builder0": builders[0], "Builder1": builders[1], "Builder2": builders[2]}[buildername]
notifier.master_status.getBuilder = fakeGetBuilder
notifier.master.db = fakedb.FakeDBConnector(self)
notifier.master.db.insertTestData([
fakedb.SourceStampSet(id=127),
fakedb.Buildset(id=99, sourcestampsetid=127, results=SUCCESS, reason="testReason"),
fakedb.BuildRequest(id=10, buildsetid=99, buildername="Builder0"),
fakedb.Build(number=0, brid=10),
fakedb.BuildRequest(id=11, buildsetid=99, buildername="Builder1"),
fakedb.Build(number=0, brid=11),
fakedb.BuildRequest(id=12, buildsetid=99, buildername="Builder2"),
fakedb.Build(number=0, brid=12)
])
if info is not None:
info['bsid'] = 99
info['builds'] = builds
d = notifier._buildsetComplete(99, SUCCESS)
return d
示例7: test_sendToInterestedUsers_two_builds
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_sendToInterestedUsers_two_builds(self):
from email.Message import Message
m = Message()
mn = MailNotifier(fromaddr="[email protected]", lookup=None)
mn.sendMessage = Mock()
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername":"Builder", "brid":1}])
builder = Mock()
builder.name = "Builder"
build1 = FakeBuildStatus(name="build")
build1.result = FAILURE
build1.finished = True
build1.reason = "testReason"
build1.builder = builder
build2 = FakeBuildStatus(name="build")
build2.result = FAILURE
build2.finished = True
build2.reason = "testReason"
build2.builder = builder
def fakeCreateEmail(msgdict, builderName, title, results, builds=None,
patches=None, logs=None):
# only concerned with m['To'] and m['CC'], which are added in
# _got_recipients later
return m
mn.createEmail = fakeCreateEmail
self.db = fakedb.FakeDBConnector(self)
self.db.insertTestData([fakedb.SourceStampSet(id=1099),
fakedb.Buildset(id=99, sourcestampsetid=1099,
results=SUCCESS,
reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99,
buildername='Builder'),
fakedb.Build(number=0, brid=11),
fakedb.Build(number=1, brid=11),
fakedb.Change(changeid=9123),
fakedb.Change(changeid=9124),
fakedb.ChangeUser(changeid=9123, uid=1),
fakedb.ChangeUser(changeid=9124, uid=2),
fakedb.User(uid=1, identifier="tdurden"),
fakedb.User(uid=2, identifier="user2"),
fakedb.UserInfo(uid=1, attr_type='email',
attr_data="[email protected]"),
fakedb.UserInfo(uid=2, attr_type='email',
attr_data="[email protected]")
])
def _getInterestedUsers():
# 'narrator' in this case is the owner, which tests the lookup
return ["Big Bob <[email protected]>", "narrator"]
build1.getInterestedUsers = _getInterestedUsers
build2.getInterestedUsers = _getInterestedUsers
def _getResponsibleUsers():
return ["Big Bob <[email protected]>"]
build1.getResponsibleUsers = _getResponsibleUsers
build2.getResponsibleUsers = _getResponsibleUsers
# fake sourcestamp with relevant user bits
ss1 = Mock(name="sourcestamp")
fake_change1 = Mock(name="change")
fake_change1.number = 9123
ss1.changes = [fake_change1]
ss1.patch, ss1.addPatch = None, None
ss2 = Mock(name="sourcestamp")
fake_change2 = Mock(name="change")
fake_change2.number = 9124
ss2.changes = [fake_change2]
ss2.patch, ss1.addPatch = None, None
def fakeGetSS(ss):
return lambda: ss
build1.getSourceStamp = fakeGetSS(ss1)
build2.getSourceStamp = fakeGetSS(ss2)
mn.master = self # FIXME: Should be FakeMaster
self.status = mn.master_status = mn.buildMessageDict = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict.return_value = {"body": "body", "type": "text"}
mn.buildMessage(builder.name, [build1, build2], build1.result)
self.assertEqual(m['To'], "[email protected], [email protected]")
示例8: do_test_sendToInterestedUsers
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def do_test_sendToInterestedUsers(self, lookup=None, extraRecipients=[],
sendToInterestedUsers=True,
exp_called_with=None, exp_TO=None,
exp_CC=None):
from email.Message import Message
m = Message()
mn = MailNotifier(fromaddr='[email protected]',
lookup=lookup,
sendToInterestedUsers=sendToInterestedUsers,
extraRecipients=extraRecipients)
mn.sendMessage = Mock()
def fakeGetBuild(number):
return build
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername":"Builder", "brid":1}])
builder = Mock()
builder.getBuild = fakeGetBuild
builder.name = "Builder"
build = FakeBuildStatus(name="build")
build.result = FAILURE
build.finished = True
build.reason = "testReason"
build.builder = builder
def fakeCreateEmail(msgdict, builderName, title, results, builds=None,
patches=None, logs=None):
# only concerned with m['To'] and m['CC'], which are added in
# _got_recipients later
return m
mn.createEmail = fakeCreateEmail
self.db = fakedb.FakeDBConnector(self)
self.db.insertTestData([fakedb.SourceStampSet(id=1099),
fakedb.Buildset(id=99, sourcestampsetid=1099,
results=SUCCESS,
reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99,
buildername='Builder'),
fakedb.Build(number=0, brid=11),
fakedb.Change(changeid=9123),
fakedb.ChangeUser(changeid=9123, uid=1),
fakedb.User(uid=1, identifier="tdurden"),
fakedb.UserInfo(uid=1, attr_type='svn',
attr_data="tdurden"),
fakedb.UserInfo(uid=1, attr_type='email',
attr_data="[email protected]")
])
# fake sourcestamp with relevant user bits
ss = Mock(name="sourcestamp")
fake_change = Mock(name="change")
fake_change.number = 9123
ss.changes = [fake_change]
ss.patch, ss.addPatch = None, None
def fakeGetSS():
return ss
build.getSourceStamp = fakeGetSS
def _getInterestedUsers():
# 'narrator' in this case is the owner, which tests the lookup
return ["Big Bob <[email protected]>", "narrator"]
build.getInterestedUsers = _getInterestedUsers
def _getResponsibleUsers():
return ["Big Bob <[email protected]>"]
build.getResponsibleUsers = _getResponsibleUsers
mn.master = self # FIXME: Should be FakeMaster
self.status = mn.master_status = mn.buildMessageDict = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict.return_value = {"body": "body", "type": "text"}
mn.buildMessage(builder.name, [build], build.result)
mn.sendMessage.assert_called_with(m, exp_called_with)
self.assertEqual(m['To'], exp_TO)
self.assertEqual(m['CC'], exp_CC)
示例9: run_fake_summary_build
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def run_fake_summary_build(self, buildResults, finalResult, resultText, verifiedScore):
gsp = GerritStatusPush('host.example.com', 'username', summaryCB=testSummaryCB)
buildpairs = []
i = 0
for i in xrange(len(buildResults)):
buildResult = buildResults[i]
builder = Mock()
build = FakeBuildStatus()
builder.getBuild.return_value = build
builder.name = "Builder-%d" % i
builder.getName.return_value = builder.name
build.results = buildResult
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
build.getResults.return_value = build.results
build.getText.return_value = ['buildText']
build.getProperty = lambda prop: self.TEST_PROPS.get(prop)
buildpairs.append((builder, build))
def fakeGetBuilder(buildername):
# e.g. Builder-5 will be buildpairs[5][0]
return buildpairs[int(buildername.split("-")[1])][0]
self.run_prepare_gsp(gsp)
gsp.master_status.getBuilder = fakeGetBuilder
gsp.master_status.getURLForThing = Mock()
gsp.master_status.getURLForThing.return_value = self.THING_URL
gsp.master.db = fakedb.FakeDBConnector(gsp.master, self)
fakedata = [
fakedb.Master(id=92),
fakedb.Buildslave(id=13, name='sl'),
fakedb.Buildset(id=99, results=finalResult, reason="testReason"),
]
breqid = 1000
for (builder, build) in buildpairs:
fakedata.append(fakedb.BuildRequest(id=breqid, buildsetid=99,
buildername=builder.name))
fakedata.append(fakedb.Build(number=0, buildrequestid=breqid,
masterid=92, buildslaveid=13))
breqid = breqid + 1
gsp.master.db.insertTestData(fakedata)
fakeSCR = Mock()
gsp.sendCodeReview = fakeSCR
d = gsp._buildsetComplete('buildset.99.complete',
dict(bsid=99, result=SUCCESS))
@d.addCallback
def check(_):
info = []
for i in xrange(len(buildResults)):
info.append({'name': "Builder-%d" % i, 'result': buildResults[i],
'resultText': resultText[i], 'text': 'buildText',
'url': self.THING_URL})
fakeSCR.assert_called_once_with(self.TEST_PROJECT, self.TEST_REVISION, str(info), verifiedScore, 0)
return d
示例10: test_getCustomMesgData_single_sourcestamp
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_getCustomMesgData_single_sourcestamp(self):
self.passedAttrs = {}
def fakeCustomMessage(attrs):
self.passedAttrs = attrs
return ("", "")
mn = MailNotifier('[email protected]',
buildSetSummary=True,
mode=("failing", "passing", "warnings"),
builders=["Builder"])
def fakeBuildMessage(name, builds, results):
for build in builds:
mn.buildMessageDict(name=build.getBuilder().name,
build=build, results=build.results)
mn.buildMessage = fakeBuildMessage
mn.customMesg = fakeCustomMessage
def fakeGetBuild(number):
return build
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername": "Builder", "brid": 1}])
self.db = fakedb.FakeDBConnector(self)
self.db.insertTestData([fakedb.SourceStampSet(id=127),
fakedb.Buildset(id=99, sourcestampsetid=127,
results=SUCCESS,
reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99,
buildername='Builder'),
fakedb.Build(number=0, brid=11),
])
mn.master = self
builder = Mock()
builder.getBuild = fakeGetBuild
builder.name = "Builder"
build = FakeBuildStatus()
build.results = FAILURE
build.finished = True
build.reason = "testReason"
build.getLogs.return_value = []
build.getBuilder.return_value = builder
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
ss1 = FakeSource(revision='111222', codebase='testlib1')
build.getSourceStamps.return_value = [ss1]
mn.buildsetFinished(99, FAILURE)
self.assertTrue('builderName' in self.passedAttrs, "No builderName entry found in attrs")
self.assertEqual(self.passedAttrs['builderName'], 'Builder')
self.assertTrue('revision' in self.passedAttrs, "No revision entry found in attrs")
self.assertTrue(isinstance(self.passedAttrs['revision'], str))
self.assertEqual(self.passedAttrs['revision'], '111222')
示例11: test_getCustomMesgData_single_sourcestamp
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_getCustomMesgData_single_sourcestamp(self):
self.passedAttrs = {}
def fakeCustomMessage(attrs):
self.passedAttrs = attrs
return ("", "")
mn = MailNotifier(
"[email protected]", buildSetSummary=True, mode=("failing", "passing", "warnings"), builders=["Builder"]
)
def fakeBuildMessage(name, builds, results):
for build in builds:
mn.buildMessageDict(name=build.getBuilder().name, build=build, results=build.results)
mn.buildMessage = fakeBuildMessage
mn.customMesg = fakeCustomMessage
def fakeGetBuild(number):
return build
def fakeGetBuilder(buildername):
if buildername == builder.name:
return builder
return None
def fakeGetBuildRequests(self, bsid):
return defer.succeed([{"buildername": "Builder", "brid": 1}])
self.db = self.master.db
self.db.insertTestData(
[
fakedb.Master(id=22),
fakedb.Buildslave(id=13, name="sl"),
fakedb.Builder(id=80, name="Builder"),
fakedb.Buildset(id=99, results=SUCCESS, reason="testReason"),
fakedb.BuildRequest(id=11, buildsetid=99, builderid=80),
fakedb.Build(number=0, buildrequestid=11, buildslaveid=13, masterid=22),
]
)
mn.master = self.master
builder = Mock()
builder.getBuild = fakeGetBuild
builder.name = "Builder"
build = FakeBuildStatus()
build.results = FAILURE
build.finished = True
build.reason = "testReason"
build.getLogs.return_value = []
build.getBuilder.return_value = builder
build.getResults.return_value = build.results
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
ss1 = FakeSource(revision="111222", codebase="testlib1")
build.getSourceStamps.return_value = [ss1]
d = mn._buildsetComplete("buildset.99.complete", dict(bsid=99, result=FAILURE))
@d.addCallback
def check(_):
self.assertTrue("builderName" in self.passedAttrs, "No builderName entry found in attrs")
self.assertEqual(self.passedAttrs["builderName"], "Builder")
self.assertTrue("revision" in self.passedAttrs, "No revision entry found in attrs")
self.assertTrue(isinstance(self.passedAttrs["revision"], str))
self.assertEqual(self.passedAttrs["revision"], "111222")
return d
示例12: test_buildsetComplete_sends_email
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def test_buildsetComplete_sends_email(self):
fakeBuildMessage = Mock()
mn = MailNotifier(
"[email protected]",
buildSetSummary=True,
mode=("failing", "passing", "warnings"),
builders=["Builder1", "Builder2"],
)
mn.buildMessage = fakeBuildMessage
builder1 = Mock()
builder1.getBuild = lambda number: build1
builder1.name = "Builder1"
build1 = FakeBuildStatus()
build1.results = FAILURE
build1.finished = True
build1.reason = "testReason"
build1.getBuilder.return_value = builder1
build1.getResults.return_value = build1.results
builder2 = Mock()
builder2.getBuild = lambda number: build2
builder2.name = "Builder2"
build2 = FakeBuildStatus()
build2.results = FAILURE
build2.finished = True
build2.reason = "testReason"
build2.getBuilder.return_value = builder1
build2.getResults.return_value = build2.results
def fakeGetBuilder(buildername):
return {"Builder1": builder1, "Builder2": builder2}[buildername]
self.db = self.master.db
self.db.insertTestData(
[
fakedb.Master(id=92),
fakedb.Buildslave(id=13, name="sl"),
fakedb.Buildset(id=99, results=SUCCESS, reason="testReason"),
fakedb.Builder(id=80, name="Builder1"),
fakedb.Builder(id=81, name="Builder2"),
fakedb.BuildRequest(id=11, buildsetid=99, builderid=80),
fakedb.Build(number=0, buildrequestid=11, buildslaveid=13, masterid=92),
fakedb.BuildRequest(id=12, buildsetid=99, builderid=81),
fakedb.Build(number=0, buildrequestid=12, buildslaveid=13, masterid=92),
]
)
mn.master = self.master
self.status = Mock()
mn.master_status = Mock()
mn.master_status.getBuilder = fakeGetBuilder
mn.buildMessageDict = Mock()
mn.buildMessageDict.return_value = {"body": "body", "type": "text", "subject": "subject"}
d = mn._buildsetComplete("buildset.99.complete", dict(bsid=99, result=FAILURE))
@d.addCallback
def check(_):
fakeBuildMessage.assert_called_with("(whole buildset)", [build1, build2], SUCCESS)
return d
示例13: run_fake_summary_build
# 需要导入模块: from buildbot.test.fake.fakebuild import FakeBuildStatus [as 别名]
# 或者: from buildbot.test.fake.fakebuild.FakeBuildStatus import finished [as 别名]
def run_fake_summary_build(self, gsp, buildResults, finalResult,
resultText, expWarning=False):
buildpairs = []
i = 0
for i in xrange(len(buildResults)):
buildResult = buildResults[i]
builder = Mock()
build = FakeBuildStatus()
builder.getBuild.return_value = build
builder.name = "Builder-%d" % i
builder.getName.return_value = builder.name
builder._builderid = i
build.results = buildResult
build.finished = True
build.reason = "testReason"
build.getBuilder.return_value = builder
build.getResults.return_value = build.results
build.getText.return_value = ['buildText']
build.getProperty = self.TEST_PROPS.get
buildpairs.append((builder, build))
def fakeGetBuilder(buildername):
# e.g. Builder-5 will be buildpairs[5][0]
return buildpairs[int(buildername.split("-")[1])][0]
gsp.master_status.getBuilder = fakeGetBuilder
gsp.master_status.getURLForThing = Mock()
gsp.master_status.getURLForThing.return_value = self.THING_URL
gsp.master.db = fakedb.FakeDBConnector(gsp.master, self)
fakedata = [
fakedb.Master(id=92),
fakedb.Buildslave(id=13, name='sl'),
fakedb.Buildset(id=99, results=finalResult, reason="testReason"),
]
breqid = 1000
for (builder, build) in buildpairs:
fakedata.append(fakedb.Builder(id=builder._builderid, name=builder.name))
fakedata.append(fakedb.BuildRequest(id=breqid, buildsetid=99,
builderid=builder._builderid))
fakedata.append(fakedb.Build(number=0, buildrequestid=breqid,
masterid=92, buildslaveid=13))
breqid = breqid + 1
gsp.master.db.insertTestData(fakedata)
d = gsp._buildsetComplete('buildset.99.complete',
dict(bsid=99, result=SUCCESS))
@d.addCallback
def check(_):
info = []
for i in xrange(len(buildResults)):
info.append({'name': "Builder-%d" % i, 'result': buildResults[i],
'resultText': resultText[i], 'text': 'buildText',
'url': self.THING_URL})
if expWarning:
self.assertEqual([w['message'] for w in self.flushWarnings()],
['The Gerrit status callback uses the old '
'way to communicate results. The outcome '
'might be not what is expected.'])
return str(info)
return d