mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-23 11:28:13 +01:00
63d3b2b5cf
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmHbOcMACgkQA0U5G1Wq FSEGVA//Vjgripk0eRDIUZrdL/knjDXybbHVz06r+gx+9Rh1b+3MJ8t+VAjeX7OO iJns7ZysKgMsQSYFCFk9fTl5m3ECzZFmzY7lmRU2tU6Hz9lUwotN70e+zGBgFE6J sGji4YOCrUnpmgb0j0joRD565m74Bi2Z8Pj+qRvo4RcQY5JxczyDtkSnLb9UDo/e FNZ4bTlwJL13Jeu8F6BtnCFPxvpac3qlzLIlG327Fz4cFwQ+QoxQIq5i8pnOu3B2 HBEyOZAgIuONbV/RH/nwt7QmT45Dne1wP/UqocHkiu3yKvsCRLZC0vsejw8/dZ+D GQUfJT9EL1AIJa6OvUyF5UtnPMRKgACG2nt5U8M02ubheAAEgUS/FIIm1kgxkqYU 5dDKHwU12YHDW2/nwOSRBFDV6TSCkskXr9Thr884KCobyPPnhWkN+pKAfyDhwPMc MrnMyId3fPrJRPMxoQ7Z8TJV8l/Wd6FIlFowfzk+s6hfV2qgOUZJ2Btrfk8596Sy np8usullbhFagYQ1+JX3AvVxLYvtFKmxO/qG6TcBmjBui5ABz7wtizfgwDx5eVJr GpzJUKFUKAmZW+15nm3oNdEwFOjdvRouKc03Qv5eCU6wSaOtd9efgntDPcso8ycW Us13KJIhwmwDJdaqnlmG5TdlJY9qjFu/VGHt4+I1GNQuswXRIo8= =hQCB -----END PGP SIGNATURE----- Merge tag '0.34.3' notmuch 0.34.3 release
109 lines
2.5 KiB
Python
109 lines
2.5 KiB
Python
import collections.abc
|
|
import time
|
|
|
|
import pytest
|
|
|
|
import notmuch2
|
|
|
|
|
|
@pytest.fixture
|
|
def thread(maildir, notmuch):
|
|
"""Return a single thread with one matched message."""
|
|
msgid, _ = maildir.deliver(body='foo')
|
|
maildir.deliver(body='bar',
|
|
headers=[('In-Reply-To', '<{}>'.format(msgid))])
|
|
notmuch('new')
|
|
with notmuch2.Database(maildir.path, config=notmuch2.Database.CONFIG.EMPTY) as db:
|
|
yield next(db.threads('foo'))
|
|
|
|
|
|
def test_type(thread):
|
|
assert isinstance(thread, notmuch2.Thread)
|
|
assert isinstance(thread, collections.abc.Iterable)
|
|
|
|
|
|
def test_threadid(thread):
|
|
assert isinstance(thread.threadid, notmuch2.BinString)
|
|
assert thread.threadid
|
|
|
|
|
|
def test_len(thread):
|
|
assert len(thread) == 2
|
|
|
|
|
|
def test_toplevel_type(thread):
|
|
assert isinstance(thread.toplevel(), collections.abc.Iterator)
|
|
|
|
|
|
def test_toplevel(thread):
|
|
msgs = thread.toplevel()
|
|
assert isinstance(next(msgs), notmuch2.Message)
|
|
with pytest.raises(StopIteration):
|
|
next(msgs)
|
|
|
|
|
|
def test_toplevel_reply(thread):
|
|
msg = next(thread.toplevel())
|
|
assert isinstance(next(msg.replies()), notmuch2.Message)
|
|
|
|
|
|
def test_iter(thread):
|
|
msgs = list(iter(thread))
|
|
assert len(msgs) == len(thread)
|
|
for msg in msgs:
|
|
assert isinstance(msg, notmuch2.Message)
|
|
|
|
|
|
def test_matched(thread):
|
|
assert thread.matched == 1
|
|
|
|
def test_matched_iter(thread):
|
|
count = 0
|
|
msgs = list(iter(thread))
|
|
for msg in msgs:
|
|
if msg.matched:
|
|
count += 1
|
|
assert count == thread.matched
|
|
|
|
def test_authors_type(thread):
|
|
assert isinstance(thread.authors, notmuch2.BinString)
|
|
|
|
|
|
def test_authors(thread):
|
|
assert thread.authors == 'src@example.com'
|
|
|
|
|
|
def test_subject(thread):
|
|
assert thread.subject == 'Test mail'
|
|
|
|
|
|
def test_first(thread):
|
|
# XXX Someone seems to treat things as local time instead of
|
|
# UTC or the other way around.
|
|
now = int(time.time())
|
|
assert abs(now - thread.first) < 3600*24
|
|
|
|
|
|
def test_last(thread):
|
|
# XXX Someone seems to treat things as local time instead of
|
|
# UTC or the other way around.
|
|
now = int(time.time())
|
|
assert abs(now - thread.last) < 3600*24
|
|
|
|
|
|
def test_first_last(thread):
|
|
# Sadly we only have second resolution so these will always be the
|
|
# same time in our tests.
|
|
assert thread.first <= thread.last
|
|
|
|
|
|
def test_tags_type(thread):
|
|
assert isinstance(thread.tags, notmuch2.ImmutableTagSet)
|
|
|
|
|
|
def test_tags_cache(thread):
|
|
assert thread.tags is thread.tags
|
|
|
|
|
|
def test_tags(thread):
|
|
assert 'inbox' in thread.tags
|