def test_allow_comma_in_receiver_issue_14(self): """ Test if email is sent to the correct contact, containing comma in name """ my_sender = 'Me <*****@*****.**>' to = '"Leo2, Ianna" <*****@*****.**>, "Leo, Iannacone" <*****@*****.**>' payload = 'This is the payload of test_remove_bcc_from_header' m = MIMEText(payload) m['To'] = to m['From'] = my_sender addr = Gmail._get_receivers(m) self.assertIn("*****@*****.**", addr) self.assertIn("*****@*****.**", addr)
def test_do_not_duplicate_senders(self): """ Test if email is sent twice to the same receiver """ my_sender = 'Me <*****@*****.**>' to = '"Leo2, Ianna" <*****@*****.**>, "Leo, Iannacone" <*****@*****.**>' payload = 'This is the payload of test_remove_bcc_from_header' m = MIMEText(payload) m['To'] = to m['From'] = my_sender addr = Gmail._get_receivers(m) self.assertEqual(1, len(addr)) self.assertIn("*****@*****.**", addr)
def test_sends_to_everyone(self): """ Tests if message is going to be sent to: To: CC: Bcc: """ my_sender = 'Me <*****@*****.**>' to = 'Leo Iannacone <*****@*****.**>' Cc = 'Leo2 Iannacone <*****@*****.**>, Leo3 Iannacone <*****@*****.**>' Bcc = 'Leo4 Iannacone <*****@*****.**>, Leo5 Iannacone <*****@*****.**>' m = Message() m['To'] = to m['Cc'] = Cc m['Bcc'] = Bcc m['From'] = my_sender my_receivers = ', '.join([to, Cc, Bcc]).split(',') my_addresses = email.utils.getaddresses(my_receivers) addresses = Gmail._get_receivers(m) for name, addr in my_addresses: self.assertIn(addr, addresses)