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)
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)
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"])
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")