summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-06-07 10:04:33 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-06-07 10:05:26 -0700
commit8969993fcbc51338c0d0c61849cf4e313f0a6125 (patch)
treede86f5f2ed29251d0a6b214ddd90c2426be34a3e /tests
parenta41abb8ffbc79e5df018f44bdf5d4d0c44a5e7f6 (diff)
tests: Add some basic test for Account
This doesn't cover the actually complex part of the of the module, but it's a few basic tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/account_test.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/account_test.py b/tests/account_test.py
new file mode 100644
index 00000000..9b4bf9c0
--- /dev/null
+++ b/tests/account_test.py
@@ -0,0 +1,54 @@
+# encoding=utf-8
+# Copyright © 2017 Dylan Baker
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import absolute_import
+import unittest
+
+from alot import account
+
+
+class _AccountTestClass(account.Account):
+ """Implements stubs for ABC methods."""
+
+ def send_mail(self, mail):
+ pass
+
+
+class TestAccount(unittest.TestCase):
+ """Tests for the Account class."""
+
+ def test_get_address(self):
+ """Tests address without aliases."""
+ acct = _AccountTestClass(address=u"foo@example.com")
+ self.assertListEqual(acct.get_addresses(), [u'foo@example.com'])
+
+ def test_get_address_with_aliases(self):
+ """Tests address with aliases."""
+ acct = _AccountTestClass(address=u"foo@example.com",
+ aliases=[u'bar@example.com'])
+ self.assertListEqual(acct.get_addresses(),
+ [u'foo@example.com', u'bar@example.com'])
+
+ def test_deprecated_encrypt_by_default(self):
+ """Tests that depreacted values are still accepted."""
+ for each in [u'true', u'yes', u'1']:
+ acct = _AccountTestClass(address=u'foo@example.com',
+ encrypt_by_default=each)
+ self.assertEqual(acct.encrypt_by_default, u'all')
+ for each in [u'false', u'no', u'0']:
+ acct = _AccountTestClass(address=u'foo@example.com',
+ encrypt_by_default=each)
+ self.assertEqual(acct.encrypt_by_default, u'none')