summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/db/message.py8
-rw-r--r--tests/db/test_message.py13
2 files changed, 11 insertions, 10 deletions
diff --git a/alot/db/message.py b/alot/db/message.py
index 8c3392e9..67a16e1e 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -25,14 +25,14 @@ class Message:
It it uses a :class:`~alot.db.DBManager` for cached manipulation
and lazy lookups.
"""
- def __init__(self, dbman, msg, thread=None):
+ def __init__(self, dbman, msg, thread):
"""
:param dbman: db manager that is used for further lookups
:type dbman: alot.db.DBManager
:param msg: the wrapped message
:type msg: notmuch.database.Message
- :param thread: this messages thread (will be looked up later if `None`)
- :type thread: :class:`~alot.db.Thread` or `None`
+ :param thread: this messages thread
+ :type thread: :class:`~alot.db.Thread`
"""
self._dbman = dbman
self._id = msg.get_message_id()
@@ -125,8 +125,6 @@ class Message:
def get_thread(self):
"""returns the :class:`~alot.db.Thread` this msg belongs to"""
- if not self._thread:
- self._thread = self._dbman.get_thread(self._thread_id)
return self._thread
def get_datestring(self):
diff --git a/tests/db/test_message.py b/tests/db/test_message.py
index adc099f6..953d0fe4 100644
--- a/tests/db/test_message.py
+++ b/tests/db/test_message.py
@@ -65,7 +65,8 @@ class TestMessage(unittest.TestCase):
email address is provided.
"""
msg = message.Message(mock.Mock(),
- MockNotmuchMessage({'From': 'user@example.com'}))
+ MockNotmuchMessage({'From': 'user@example.com'}),
+ mock.Mock())
self.assertEqual(msg.get_author(), ('', 'user@example.com'))
def test_get_author_name_and_email(self):
@@ -74,7 +75,8 @@ class TestMessage(unittest.TestCase):
"""
msg = message.Message(
mock.Mock(),
- MockNotmuchMessage({'From': '"User Name" <user@example.com>'}))
+ MockNotmuchMessage({'From': '"User Name" <user@example.com>'}),
+ mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_sender(self):
@@ -83,7 +85,8 @@ class TestMessage(unittest.TestCase):
"""
msg = message.Message(
mock.Mock(),
- MockNotmuchMessage({'Sender': '"User Name" <user@example.com>'}))
+ MockNotmuchMessage({'Sender': '"User Name" <user@example.com>'}),
+ mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_no_name_draft(self):
@@ -96,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(), MockNotmuchMessage(tags=['draft']), mock.Mock())
self.assertEqual(msg.get_author(), ('User Name', 'user@example.com'))
def test_get_author_no_name(self):
@@ -108,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())
+ msg = message.Message(mock.Mock(), MockNotmuchMessage(), mock.Mock())
self.assertEqual(msg.get_author(), ('Unknown', ''))