Exemplo n.º 1
0
    def _mail_missing_message(self, subject, text):
        # FIXME: This should be handled properly via the event api
        # we should send a missing message on the mq, and let any reporter
        # handle that

        # first, see if we have a MailNotifier we can use. This gives us a
        # fromaddr and a relayhost.
        buildmaster = self.botmaster.master
        for st in buildmaster.services:
            if isinstance(st, MailNotifier):
                break
        else:
            # if not, they get a default MailNotifier, which always uses SMTP
            # to localhost and uses a dummy fromaddr of "buildbot".
            log.msg("worker-missing msg using default MailNotifier")
            st = MailNotifier("buildbot")
        # now construct the mail

        m = Message()
        m.set_payload(text)
        m['Date'] = formatdate(localtime=True)
        m['Subject'] = subject
        m['From'] = st.fromaddr
        recipients = self.notify_on_missing
        m['To'] = ", ".join(recipients)
        d = st.sendMessage(m, recipients)
        # return the Deferred for testing purposes
        return d
Exemplo n.º 2
0
 def test_notifiy_for_buildset(self):
     yield self.setupConfig(masterConfig())
     self.master.config.services = [
         MailNotifier("*****@*****.**", mode="all", buildSetSummary=True)
     ]
     yield self.master.reconfigServiceWithBuildbotConfig(self.master.config)
     yield self.doTest()
Exemplo n.º 3
0
 def test_notifiy_for_buildset(self):
     self.master.config.services = [
         MailNotifier("*****@*****.**", mode="all", buildSetSummary=True),
         PushoverNotifier('1234', 'abcd', mode="all", buildSetSummary=True,
             messageFormatter=MessageFormatter(template='This is a message.'))]
     yield self.master.reconfigServiceWithBuildbotConfig(self.master.config)
     yield self.doTest('whole buildset')
Exemplo n.º 4
0
 def test_invalid_email(self):
     for invalid in ['@', 'foo', 'foo@', '@example.com', 'foo@invalid',
                     'foobar@ex+ample.com',        # + in domain part
                     # whitespace in local part
                     'foo [email protected]',
                     'Foo\nBar <*****@*****.**>',  # newline in name
                     '*****@*****.**']:     # empty label (..)
         with self.assertRaises(ConfigErrors):
             MailNotifier('*****@*****.**', extraRecipients=[invalid])
Exemplo n.º 5
0
    def test_valid_emails(self):
        valid_emails = [
            '*****@*****.**',            # + comment in local part
            '[email protected].',            # root dot
            'My Name <*****@*****.**>',  # With full name
            '<*****@*****.**>',          # With <>
            'My Name <[email protected].>',  # With full name (root dot)
            '[email protected]']       # IDN TLD (.misr, Egypt)

        # If any of these email addresses fail, the test fails by
        # yield self.setupMailNotifier raising a ConfigErrors exception.
        MailNotifier('*****@*****.**', extraRecipients=valid_emails)
Exemplo n.º 6
0
 def setupMailNotifier(self, *args, **kwargs):
     mn = MailNotifier(*args, **kwargs)
     yield mn.setServiceParent(self.master)
     yield mn.startService()
     return mn
Exemplo n.º 7
0
 def test_init_warns_notifier_mode_all_in_iter(self):
     self.assertRaisesConfigError(
         "mode 'all' is not valid in an iterator and must be passed in as a separate string",
         lambda: MailNotifier('*****@*****.**', mode=['all']))
Exemplo n.º 8
0
 def setupMailNotifier(self, *args, **kwargs):
     mn = MailNotifier(*args, **kwargs)
     yield mn.setServiceParent(self.master)
     yield mn.startService()
     defer.returnValue(mn)