Exemple #1
0
 def test_getAndSetAddresses(self):
     notifier  = Notifier(skipEmails = "*****@*****.**"
                        , test       = True
                        , log        = False)
     addresses = ["*****@*****.**", "*****@*****.**"]
     e1 = Email()
     e2 = Email()
     notifier.registerTemplate("test", e1)
     notifier.registerTemplate("frog", e2)
     notifier.setAddresses("test", addresses)
     notifier.setAddresses("frog", ["frog@pond", "toad@toadstool"])
     results = notifier.getAddresses("test")
     self.assertEquals(results, ["*****@*****.**"])
     results = notifier.getAddresses("frog")
     self.assertEquals(results, ["frog@pond", "toad@toadstool"])
Exemple #2
0
    def test_disbledLogging(self):
        # Don't send emails, and don't write out the log file.
        message  = "test test test"
        notifier = Notifier(test = True, log = False)
        notifier.startLogging()
        notifier.logMessage(message)
        notifier.stopLogging()

        self.assertEquals(None, notifier.logfilename)
Exemple #3
0
 def test_getAndSetBody(self):
     notifier  = Notifier(test = True, log = False)
     body1     = "Yadda yadda yadda"
     body2     = "Aren't they, though?"
     e1 = Email()
     e2 = Email()
     notifier.registerTemplate("test", e1)
     notifier.registerTemplate("frog", e2)
     notifier.setBody("test", body1)
     notifier.setBody("frog", body2)
     results = notifier.getBody("test")
     self.assertEquals(results, body1)
     results = notifier.getBody("frog")
     self.assertEquals(results, body2)
Exemple #4
0
 def test_getAndSetSubject(self):
     notifier  = Notifier(test = True, log = False)
     subject1  = "Send cash now!"
     subject2  = "Flies are so yummy!"
     e1 = Email()
     e2 = Email()
     notifier.registerTemplate("test", e1)
     notifier.registerTemplate("frog", e2)
     notifier.setSubject("test", subject1)
     notifier.setSubject("frog", subject2)
     results = notifier.getSubject("test")
     self.assertEquals(results, subject1)
     results = notifier.getSubject("frog")
     self.assertEquals(results, subject2)
Exemple #5
0
    def test_enabledLogging(self):
        # Don't send emails, but write out the log file.
        message  = "test test test"
        notifier = Notifier(test = True, log = True)
        notifier.startLogging()
        notifier.logMessage(message)
        notifier.stopLogging()

        file     = open(notifier.logfilename, "r")
        contents = file.read()
        self.assertTrue(message in contents)
        self.assertTrue("Notification sent on" in contents)
        file.close()

        os.remove(notifier.logfilename)
Exemple #6
0
    def test_email_templates(self):
        notifier = Notifier(test = True, log = False)
        sender = "frog@pond"
        recipients = ["toad@toadstool", "salamander@leafpile"]
        subject = "Life is good!"
        body = "Living in the pond is heaven!"
        e1 = Email(sender = sender,
                   recipients = recipients,
                   subject = subject,
                   body = body)
        notifier.registerTemplate("pond", e1)
        e2 = notifier.cloneTemplate("pond")

        self.assertEquals(e2.GetSender(), sender)
        self.assertEquals(e2.GetRecipientList(), recipients)
        self.assertEquals(e2.GetSubject(), subject)
        self.assertEquals(e2.GetBody(), body)

        notifier.unregisterTemplate("pond")
        self.assertRaises(KeyError, notifier.cloneTemplate, "pond")