Exemplo n.º 1
0
    def test_getCustomMesgData_single_sourcestamp(self):
        self.passedAttrs = {}

        def fakeCustomMessage(attrs):
            self.passedAttrs = attrs
            return ("", "")

        mn = MailNotifier('*****@*****.**',
                          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')
Exemplo n.º 2
0
    def test_getCustomMesgData_single_sourcestamp(self):
        self.passedAttrs = {}

        def fakeCustomMessage(attrs):
            self.passedAttrs = attrs
            return ("", "")

        mn = MailNotifier(
            "*****@*****.**", 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
Exemplo n.º 3
0
    def test_getCustomMesgData_single_sourcestamp(self):
        self.passedAttrs = {}

        def fakeCustomMessage(attrs):
            self.passedAttrs = attrs
            return ("", "")

        mn = MailNotifier('*****@*****.**',
                          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')
Exemplo n.º 4
0
    def test_getCustomMesgData_single_sourcestamp(self):
        self.passedAttrs = {}

        def fakeCustomMessage(attrs):
            self.passedAttrs = attrs
            return ("", "")

        mn = MailNotifier('*****@*****.**',
                          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),
        ])
        self.setupMailNotifier(mn)

        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

        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