def test_cc(self): mailgun_data = {"from": "*****@*****.**", "to": ["*****@*****.**", ], "cc": ["*****@*****.**", "*****@*****.**", "*****@*****.**"], "subject": "subject", "text": "This is text content", } mailgun.clean_mailgun_data(mailgun_data) cc_list = mailgun_data["cc"] self.assertEqual(1, len(cc_list)) self.assertTrue("*****@*****.**" in cc_list) self.assertFalse("*****@*****.**" in cc_list) self.assertFalse("*****@*****.**" in cc_list) self.assertEqual(mailgun_data['bcc'], [])
def test_simple(self): mailgun_data = {"from": "*****@*****.**", "to": ["*****@*****.**", ], "subject": "subject", "text": "This is text content", "html": "<p>This is <em>HTML</em> content</p>", } mailgun.clean_mailgun_data(mailgun_data) self.assertEqual("*****@*****.**", mailgun_data["from"]) self.assertEqual("subject", mailgun_data["subject"]) self.assertEqual("This is text content", mailgun_data["text"]) self.assertEqual("<p>This is <em>HTML</em> content</p>", mailgun_data["html"]) to_list = mailgun_data["to"] self.assertEqual(1, len(to_list)) self.assertEqual("*****@*****.**", to_list[0]) self.assertEqual(mailgun_data['cc'], []) self.assertEqual(mailgun_data['bcc'], [])
def test_multiple_to(self): mailgun_data = {"from": "*****@*****.**", "to": ["*****@*****.**", "*****@*****.**", "*****@*****.**"], "cc": ["*****@*****.**"], "bcc": ["*****@*****.**"], "subject": "subject", "text": "This is text content", } mailgun.clean_mailgun_data(mailgun_data) self.assertEqual(1, len(mailgun_data["cc"])) self.assertTrue("*****@*****.**" in mailgun_data["cc"]) self.assertEqual(1, len(mailgun_data["bcc"])) self.assertTrue("*****@*****.**" in mailgun_data["bcc"]) self.assertEqual(2, len(mailgun_data["to"])) self.assertTrue("*****@*****.**" in mailgun_data["to"]) self.assertTrue("*****@*****.**" in mailgun_data["to"]) self.assertFalse("*****@*****.**" in mailgun_data["to"])
def test_clean_mailgun_data(self): clean_data = mailgun.clean_mailgun_data(self.mailgun_data) # print(clean_data) tos = clean_data['to'] self.assertEqual(len(tos), 1) self.assertEqual(tos[0], self.alice) ccs = clean_data['cc'] self.assertEqual(len(ccs), 0) bccs = clean_data['bcc'] self.assertEqual(len(bccs), 1) self.assertEqual(bccs[0], self.frank)