summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-02-27 18:18:19 +0100
committerAnton Khirnov <anton@khirnov.net>2020-02-27 18:18:19 +0100
commitd1cf87d5375c146c18d7c442c5a1f5d2fc481a55 (patch)
tree6457151269f1073bd241394c5242f918c243782f /tests
parent8422972845bed9253d7a5dad2b901fa4247708cd (diff)
Update tests.
Drop useless db/thread test.
Diffstat (limited to 'tests')
-rw-r--r--tests/db/test_message.py16
-rw-r--r--tests/db/test_thread.py75
2 files changed, 8 insertions, 83 deletions
diff --git a/tests/db/test_message.py b/tests/db/test_message.py
index 43b06e19..cd50ab45 100644
--- a/tests/db/test_message.py
+++ b/tests/db/test_message.py
@@ -64,9 +64,9 @@ class TestMessage(unittest.TestCase):
"""Message._from is populated using the 'From' header when only an
email address is provided.
"""
- msg = message.Message(mock.Mock(),
+ msg = message.Message(mock.Mock(), mock.Mock(),
MockNotmuchMessage({'From': 'user@example.com'}),
- mock.Mock(), mock.Mock())
+ mock.Mock())
self.assertEqual(msg.get_author(), ('', 'user@example.com'))
def test_get_author_name_and_email(self):
@@ -74,9 +74,9 @@ class TestMessage(unittest.TestCase):
name are provided.
"""
msg = message.Message(
- mock.Mock(),
+ mock.Mock(), mock.Mock(),
MockNotmuchMessage({'From': '"User Name" <user@example.com>'}),
- mock.Mock(), mock.Mock())
+ mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_sender(self):
@@ -84,9 +84,9 @@ class TestMessage(unittest.TestCase):
header is present.
"""
msg = message.Message(
- mock.Mock(),
+ mock.Mock(), mock.Mock(),
MockNotmuchMessage({'Sender': '"User Name" <user@example.com>'}),
- mock.Mock(), mock.Mock())
+ mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_no_name_draft(self):
@@ -99,7 +99,7 @@ class TestMessage(unittest.TestCase):
with mock.patch('alot.db.message.settings.get_accounts',
mock.Mock(return_value=[acc])):
msg = message.Message(
- mock.Mock(), MockNotmuchMessage(tags=['draft']), mock.Mock(), mock.Mock())
+ mock.Mock(), mock.Mock(), MockNotmuchMessage(tags=['draft']), mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_no_name(self):
@@ -111,5 +111,5 @@ class TestMessage(unittest.TestCase):
acc.realname = 'User Name'
with mock.patch('alot.db.message.settings.get_accounts',
mock.Mock(return_value=[acc])):
- msg = message.Message(mock.Mock(), MockNotmuchMessage(), mock.Mock(), mock.Mock())
+ msg = message.Message(mock.Mock(), mock.Mock(), MockNotmuchMessage(), mock.Mock())
self.assertEqual(msg.get_author(), ('Unknown', ''))
diff --git a/tests/db/test_thread.py b/tests/db/test_thread.py
deleted file mode 100644
index 8b43b0b9..00000000
--- a/tests/db/test_thread.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# encoding=utf-8
-# Copyright © 2016 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/>.
-
-"""Tests for the alot.db.thread module."""
-import datetime
-import unittest
-from unittest import mock
-
-from alot.db import thread
-
-
-class TestThreadGetAuthor(unittest.TestCase):
-
- __patchers = []
-
- @classmethod
- def setUpClass(cls):
- get_messages = []
- for a, d in [('foo', datetime.datetime(datetime.MINYEAR, 1, day=21)),
- ('bar', datetime.datetime(datetime.MINYEAR, 1, day=17)),
- ('foo', datetime.datetime(datetime.MINYEAR, 1, day=14)),
- ('arf', datetime.datetime(datetime.MINYEAR, 1, 1, hour=1,
- minute=5)),
- ('oof', datetime.datetime(datetime.MINYEAR, 1, 1, hour=1,
- minute=10)),
- ('ooh', None)]:
- m = mock.Mock()
- m.date = d
- m.get_author = mock.Mock(return_value=a)
- get_messages.append(m)
- gm = mock.Mock()
- gm.values = mock.Mock(return_value=get_messages)
-
- cls.__patchers.extend([
- mock.patch('alot.db.thread.Thread.messages',
- new=mock.Mock(return_value=get_messages)),
- mock.patch('alot.db.thread.Thread.refresh', new=mock.Mock()),
- ])
-
- for p in cls.__patchers:
- p.start()
-
- @classmethod
- def tearDownClass(cls):
- for p in reversed(cls.__patchers):
- p.stop()
-
- def setUp(self):
- # values are cached and each test needs it's own instance.
- self.thread = thread.Thread(mock.Mock(), mock.Mock())
-
- def test_default(self):
- self.assertEqual(
- self.thread.get_authors(),
- ['arf', 'oof', 'foo', 'bar', 'ooh'])
-
- def test_latest_message(self):
- with mock.patch('alot.db.thread.settings.get',
- mock.Mock(return_value='latest_message')):
- self.assertEqual(
- self.thread.get_authors(),
- ['arf', 'oof', 'bar', 'foo', 'ooh'])