diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-07-24 16:39:31 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-07-25 09:12:03 -0700 |
commit | 6f16c8f4c985ed0b31fd5998749c09a6982c3e54 (patch) | |
tree | 0f79a9282902b8c14faf7fe2400ff32adfade477 /tests | |
parent | 4cba47a8143059a68c904e40e575fc4d493bf6de (diff) |
commands/globals: Convert Address to string for email.utils
Email utils apparently assumes it's getting a string, and calls encode
directly. This can only be hit if you have a single account configured,
not with multiple accounts.
Fixes #1277
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commands/global_test.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py index 53556c0f..b0153a45 100644 --- a/tests/commands/global_test.py +++ b/tests/commands/global_test.py @@ -149,6 +149,30 @@ class TestComposeCommand(unittest.TestCase): 'Subject': [subject]}, cmd.envelope.headers) self.assertEqual(body, cmd.envelope.body) + @inlineCallbacks + def test_single_account_no_from(self): + # issue #1277 + envelope = self._make_envelope_mock() + del envelope.headers['From'] + account = self._make_account_mock() + account.realname = "foo" + account.address = 1 # maybe this should be a real Address? + cmd = g_commands.ComposeCommand(envelope=envelope) + + # This whole mess is required becasue ComposeCommand.apply is waaaaay + # too complicated, it needs to be split into more manageable segments. + with mock.patch('alot.commands.globals.settings.get_account_by_address', + mock.Mock(return_value=account)): + with mock.patch('alot.commands.globals.settings.get_accounts', + mock.Mock(return_value=[account])): + with mock.patch('alot.commands.globals.settings.get_addressbooks', + mock.Mock(side_effect=Stop)): + try: + yield cmd.apply(mock.Mock()) + except Stop: + pass + + class TestExternalCommand(unittest.TestCase): |