summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2017-06-23 00:23:53 +0200
committerLucas Hoffmann <l-m-h@web.de>2017-06-23 01:25:54 +0200
commit9098ea30103a4b60a563cb60b7dca4786d7530f4 (patch)
tree52bcaed927cb60de02676a1cd216d4f242c03cb6 /tests
parente072bb81c34df5516b95029022b0bff1a7c69341 (diff)
determine_sender: Add more tests
Diffstat (limited to 'tests')
-rw-r--r--tests/commands/thread_test.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/commands/thread_test.py b/tests/commands/thread_test.py
index 66d39e94..ede9e3b7 100644
--- a/tests/commands/thread_test.py
+++ b/tests/commands/thread_test.py
@@ -178,3 +178,50 @@ class TestDetermineSender(unittest.TestCase):
expected = ('to@example.com', account2)
self._test(accounts=[account1, account2, account3], expected=expected,
force_realname=True)
+
+ def test_with_force_address_main_address_is_used_regardless_of_matching_address(self):
+ # In python 3.4 this and the next test could be written as subtests.
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='bar@example.com',
+ aliases=['to@example.com'])
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('bar@example.com', account2)
+ self._test(accounts=[account1, account2, account3], expected=expected,
+ force_address=True)
+
+ def test_without_force_address_matching_address_is_used(self):
+ # In python 3.4 this and the previous test could be written as
+ # subtests.
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='bar@example.com',
+ aliases=['to@example.com'])
+ account3 = _AccountTestClass(address='baz@example.com')
+ expected = ('to@example.com', account2)
+ self._test(accounts=[account1, account2, account3], expected=expected,
+ force_address=False)
+
+ def test_uses_to_header_if_present(self):
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ expected = ('to@example.com', account2)
+ self._test(accounts=[account1, account2, account3], expected=expected)
+
+ def test_header_order_is_more_important_than_accounts_order(self):
+ account1 = _AccountTestClass(address='cc@example.com')
+ account2 = _AccountTestClass(address='to@example.com')
+ account3 = _AccountTestClass(address='bcc@example.com')
+ expected = ('to@example.com', account2)
+ self._test(accounts=[account1, account2, account3], expected=expected)
+
+ def test_accounts_can_be_found_by_alias_regex_setting(self):
+ account1 = _AccountTestClass(address='foo@example.com')
+ account2 = _AccountTestClass(address='to@example.com',
+ alias_regexp=r'to\+.*@example.com')
+ account3 = _AccountTestClass(address='bar@example.com')
+ mailstring = self.mailstring.replace('to@example.com',
+ 'to+some_tag@example.com')
+ mail = email.message_from_string(mailstring)
+ expected = ('to+some_tag@example.com', account2)
+ self._test(accounts=[account1, account2, account3], expected=expected,
+ mail=mail)