X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython-cffi%2Ftests%2Ftest_database.py;h=9b3219c00e634a9e4d91fa6d3c7c329dd8e59aa2;hb=c8ef3a944303dd0ce9e3f2e1ea55822a4a43d19f;hp=02de0f41ab27475b8a22ad35241367d994c02f54;hpb=83c2d158983875bf77a9b7662894df585b61741c;p=notmuch diff --git a/bindings/python-cffi/tests/test_database.py b/bindings/python-cffi/tests/test_database.py index 02de0f41..9b3219c0 100644 --- a/bindings/python-cffi/tests/test_database.py +++ b/bindings/python-cffi/tests/test_database.py @@ -5,10 +5,10 @@ import pathlib import pytest -import notdb -import notdb._errors as errors -import notdb._database as dbmod -import notdb._message as message +import notmuch2 +import notmuch2._errors as errors +import notmuch2._database as dbmod +import notmuch2._message as message @pytest.fixture @@ -80,7 +80,7 @@ class TestCreate: db.create(tmppath) def test_create_existing(self, tmppath, db): - with pytest.raises(errors.FileError): + with pytest.raises(errors.DatabaseExistsError): dbmod.Database.create(path=tmppath) def test_close(self, db): @@ -127,6 +127,11 @@ class TestAtomic: with pytest.raises(errors.UnbalancedAtomicError): ctx.force_end() + def test_abort(self, db): + with db.atomic() as txn: + txn.abort() + assert db.closed + class TestRevision: @@ -279,7 +284,7 @@ class TestQuery: @pytest.fixture def db(self, maildir, notmuch): - """Return a read-only notdb.Database. + """Return a read-only notmuch2.Database. The database will have 3 messages, 2 threads. """ @@ -306,7 +311,7 @@ class TestQuery: def test_message_match(self, db): msgs = db.messages('*') msg = next(msgs) - assert isinstance(msg, notdb.Message) + assert isinstance(msg, notmuch2.Message) def test_count_threads(self, db): assert db.count_threads('*') == 2 @@ -323,4 +328,15 @@ class TestQuery: def test_threads_match(self, db): threads = db.threads('*') thread = next(threads) - assert isinstance(thread, notdb.Thread) + assert isinstance(thread, notmuch2.Thread) + + def test_use_threaded_message_twice(self, db): + thread = next(db.threads('*')) + for msg in thread.toplevel(): + assert isinstance(msg, notmuch2.Message) + assert msg.alive + del msg + for msg in thread: + assert isinstance(msg, notmuch2.Message) + assert msg.alive + del msg