示例#1
0
 def test_find_email_addresses_multiple_headers_finds_some(self):
     text = "From: John Doe <*****@*****.**>, " \
         "Mary Smith <*****@*****.**>\nOther: test"
     addrs = find_email_addresses(text, ["other", "from"])
     expected = [
         Address(
             display_name="John Doe",
             username="******",
             domain="machine.example"),
         Address(
             display_name="Mary Smith",
             username="******",
             domain="example.net")]
     self.assertEqual(expected, addrs)
示例#2
0
 def test_find_email_addresses_finds_all_emails(self):
     text = "From: John Doe <*****@*****.**>, " \
         "Mary Smith <*****@*****.**>\n" \
         "To: Michael Jones <*****@*****.**>"
     addrs = find_email_addresses(text, ["all"])
     expected = [
         Address(
             display_name="John Doe",
             username="******",
             domain="machine.example"),
         Address(
             display_name="Mary Smith",
             username="******",
             domain="example.net"),
         Address(
             display_name="Michael Jones",
             username="******",
             domain="machine.example")]
     self.assertEqual(expected, addrs)
示例#3
0
 def test_find_email_addresses_non_address_header_finds_none(self):
     text = "From: John Doe <*****@*****.**>, " \
         "Mary Smith <*****@*****.**>\nOther: test"
     addrs = find_email_addresses(text, ["other"])
     expected = []
     self.assertEqual(expected, addrs)
示例#4
0
 def test_find_email_addresses_single_header_finds_one_address(self):
     text = """From: John Doe <*****@*****.**>"""
     addrs = find_email_addresses(text, ["from"])
     expected = [Address(display_name="John Doe",
                         username="******", domain="machine.example")]
     self.assertEqual(expected, addrs)
示例#5
0
 def test_find_email_addresses_empty_text_finds_none(self):
     text = ""
     addrs = find_email_addresses(text, ["from"])
     self.assertEqual([], addrs)