summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvrs <none>2018-12-08 23:21:20 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2018-12-10 10:25:49 +0000
commit4180da12e3d4244557484eaa271baf604b0baa4e (patch)
treef4439d41aaa2a8924a669b43fb5db4ba17a1d0b0 /tests
parentf7c5b841568886be64695a14f341c4c7c58b3fba (diff)
rename get_account_by_address to account_matching_address
... since accounts' addresses can overlap and get_account_by_address promises too much. Also remove now-obsolete get_addresses.
Diffstat (limited to 'tests')
-rw-r--r--tests/commands/envelope_test.py22
-rw-r--r--tests/settings/manager_test.py20
2 files changed, 21 insertions, 21 deletions
diff --git a/tests/commands/envelope_test.py b/tests/commands/envelope_test.py
index b09cddaa..76aa7e88 100644
--- a/tests/commands/envelope_test.py
+++ b/tests/commands/envelope_test.py
@@ -186,7 +186,7 @@ class TestSignCommand(unittest.TestCase):
self.assertEqual(env.sign_key, mock.sentinel.default)
ui.notify.assert_called_once()
- @mock.patch('alot.commands.envelope.settings.get_account_by_address',
+ @mock.patch('alot.commands.envelope.settings.account_matching_address',
mock.Mock(side_effect=NoMatchingAccount))
def test_apply_no_keyid_nomatchingaccount(self):
"""If there is a nokeyid and no account can be found to match the From,
@@ -359,28 +359,28 @@ class TestSendCommand(unittest.TestCase):
pass
@utilities.async_test
- async def test_get_account_by_address_with_str(self):
+ async def test_account_matching_address_with_str(self):
cmd = envelope.SendCommand(mail=self.mail)
account = mock.Mock(wraps=self.MockedAccount())
with mock.patch(
- 'alot.commands.envelope.settings.get_account_by_address',
- mock.Mock(return_value=account)) as get_account_by_address:
+ 'alot.commands.envelope.settings.account_matching_address',
+ mock.Mock(return_value=account)) as account_matching_address:
await cmd.apply(mock.Mock())
- get_account_by_address.assert_called_once_with('foo@example.com',
- return_default=True)
+ account_matching_address.assert_called_once_with('foo@example.com',
+ return_default=True)
# check that the apply did run through till the end.
account.send_mail.assert_called_once_with(self.mail)
@utilities.async_test
- async def test_get_account_by_address_with_email_message(self):
+ async def test_account_matching_address_with_email_message(self):
mail = email.message_from_string(self.mail)
cmd = envelope.SendCommand(mail=mail)
account = mock.Mock(wraps=self.MockedAccount())
with mock.patch(
- 'alot.commands.envelope.settings.get_account_by_address',
- mock.Mock(return_value=account)) as get_account_by_address:
+ 'alot.commands.envelope.settings.account_matching_address',
+ mock.Mock(return_value=account)) as account_matching_address:
await cmd.apply(mock.Mock())
- get_account_by_address.assert_called_once_with('foo@example.com',
- return_default=True)
+ account_matching_address.assert_called_once_with('foo@example.com',
+ return_default=True)
# check that the apply did run through till the end.
account.send_mail.assert_called_once_with(mail)
diff --git a/tests/settings/manager_test.py b/tests/settings/manager_test.py
index e82d5f27..21439403 100644
--- a/tests/settings/manager_test.py
+++ b/tests/settings/manager_test.py
@@ -188,7 +188,7 @@ class TestSettingsManagerExpandEnvironment(unittest.TestCase):
class TestSettingsManagerGetAccountByAddress(utilities.TestCaseClassCleanup):
- """Test the get_account_by_address helper."""
+ """Test the account_matching_address helper."""
@classmethod
def setUpClass(cls):
@@ -216,17 +216,17 @@ class TestSettingsManagerGetAccountByAddress(utilities.TestCaseClassCleanup):
cls.manager.read_config(f.name)
def test_exists_addr(self):
- acc = self.manager.get_account_by_address(u'that_guy@example.com')
+ acc = self.manager.account_matching_address(u'that_guy@example.com')
self.assertEqual(acc.realname, 'That Guy')
def test_doesnt_exist_return_default(self):
- acc = self.manager.get_account_by_address(u'doesntexist@example.com',
- return_default=True)
+ acc = self.manager.account_matching_address(u'doesntexist@example.com',
+ return_default=True)
self.assertEqual(acc.realname, 'That Guy')
def test_doesnt_exist_raise(self):
with self.assertRaises(NoMatchingAccount):
- self.manager.get_account_by_address(u'doesntexist@example.com')
+ self.manager.account_matching_address(u'doesntexist@example.com')
def test_doesnt_exist_no_default(self):
with tempfile.NamedTemporaryFile() as f:
@@ -234,11 +234,11 @@ class TestSettingsManagerGetAccountByAddress(utilities.TestCaseClassCleanup):
settings = SettingsManager()
settings.read_config(f.name)
with self.assertRaises(NoMatchingAccount):
- settings.get_account_by_address('that_guy@example.com',
- return_default=True)
+ settings.account_matching_address('that_guy@example.com',
+ return_default=True)
def test_real_name_will_be_stripped_before_matching(self):
- acc = self.manager.get_account_by_address(
+ acc = self.manager.account_matching_address(
'That Guy <a_dude@example.com>')
self.assertEqual(acc.realname, 'A Dude')
@@ -249,6 +249,6 @@ class TestSettingsManagerGetAccountByAddress(utilities.TestCaseClassCleanup):
considered the same. Among servers that do this gmail, yahoo, fastmail,
anything running Exchange (i.e., most large corporations), and others.
"""
- acc1 = self.manager.get_account_by_address('That_guy@example.com')
- acc2 = self.manager.get_account_by_address('that_guy@example.com')
+ acc1 = self.manager.account_matching_address('That_guy@example.com')
+ acc2 = self.manager.account_matching_address('that_guy@example.com')
self.assertIs(acc1, acc2)