From c42dd604ada8dba42eb3c6c8306ecea5ba1a58bb Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Wed, 15 Aug 2018 16:48:11 +0200 Subject: Add a simple test for the send_mail function This is just a simple test for the bug reported in #1303. The interesting test is marked as a known failure. --- tests/account_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/account_test.py b/tests/account_test.py index 99df9632..d78ebb13 100644 --- a/tests/account_test.py +++ b/tests/account_test.py @@ -19,6 +19,7 @@ import unittest from alot import account +from . import utilities class _AccountTestClass(account.Account): """Implements stubs for ABC methods.""" @@ -155,3 +156,21 @@ class TestAddress(unittest.TestCase): def test_cmp_empty(self): addr = account.Address('user', 'éxample.com') self.assertNotEqual(addr, '') + + +class TestSend(unittest.TestCase): + + @utilities.async_test + async def test_logs_on_success(self): + a = account.SendmailAccount(address="test@alot.dev", cmd="true") + with self.assertLogs() as cm: + await a.send_mail("some text") + #self.assertIn(cm.output, "sent mail successfullya") + self.assertIn("INFO:root:sent mail successfully", cm.output) + + @unittest.expectedFailure + @utilities.async_test + async def test_failing_sendmail_command_is_noticed(self): + a = account.SendmailAccount(address="test@alot.dev", cmd="false") + with self.assertRaises(account.SendingMailFailed): + await a.send_mail("some text") -- cgit v1.2.3