def test_multiple_to(self): # Construct a message with the FROM and another email are in TO frm = "*****@*****.**" to = "*****@*****.**" to2 = "*****@*****.**" cc = "*****@*****.**" bcc = "*****@*****.**" message = MailgunMessage(frm, to, "Test Subject", body_text="this is a test") message.add_to(frm) message.add_to(to2) message.add_cc(cc) message.add_bcc(bcc) # Make sure CC and BCC didn't get removed mailgun_data = message.get_mailgun_data() self.assertEqual(1, len(mailgun_data["cc"])) self.assertTrue(cc in mailgun_data["cc"]) self.assertEqual(1, len(mailgun_data["bcc"])) self.assertTrue(bcc in mailgun_data["bcc"]) # Make sure TO, TO2 is in TO and FROM is not self.assertEqual(2, len(mailgun_data["to"])) self.assertTrue(to in mailgun_data["to"]) self.assertTrue(to2 in mailgun_data["to"]) self.assertFalse(frm in mailgun_data["to"])
def get_sample_message(self): """Return a message with everyone in the TO, CC, and BCC.""" message = MailgunMessage(self.bob, self.alice, "Test Subject", body_text="this is a test") message.add_to(self.frank) message.add_to(self.bob) message.add_cc(self.frank) message.add_cc(self.alice) message.add_cc(self.bob) message.add_bcc(self.bob) message.add_bcc(self.alice) message.add_bcc(self.frank) return message
def test_cc(self): # Construct a message with the FROM and TO in the CC frm = "*****@*****.**" to = "*****@*****.**" cc = "*****@*****.**" message = MailgunMessage(frm, to, "Test Subject", body_text="this is a test") message.add_cc(frm) message.add_cc(to) message.add_cc(cc) # Make sure the FROM and TO got stripped out of the CC cc_list = message.get_mailgun_data()["cc"] self.assertEqual(1, len(cc_list)) self.assertTrue(cc in cc_list) self.assertFalse(to in cc_list) self.assertFalse(frm in cc_list)