diff options
| author | Anton Khirnov <anton@khirnov.net> | 2025-09-14 17:07:43 +0200 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2025-09-14 13:24:59 -0300 |
| commit | abdff73a3333b295a599135ad2777e852189e188 (patch) | |
| tree | 49b21ea4c526d5d1fb498ef9869b892ac296183d /bindings/python-cffi/tests/test_database.py | |
| parent | aa761727999b105711ba4ca789e0836a0a05cf9f (diff) | |
bindings/python-cffi: allow reopening a database
This will be useful for handling NOTMUCH_STATUS_OPERATION_INVALIDATED
errors that will be exposed through the bindings in a following commit.
Diffstat (limited to 'bindings/python-cffi/tests/test_database.py')
| -rw-r--r-- | bindings/python-cffi/tests/test_database.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bindings/python-cffi/tests/test_database.py b/bindings/python-cffi/tests/test_database.py index 1557235d..1143cf33 100644 --- a/bindings/python-cffi/tests/test_database.py +++ b/bindings/python-cffi/tests/test_database.py @@ -173,6 +173,32 @@ class TestRevision: # XXX add tests for revisions comparisons + +class TestMode: + + def test_readonly_raises(self, db, maildir): + with pytest.raises(errors.ReadOnlyDatabaseError): + with dbmod.Database(maildir.path, 'ro', + config=notmuch2.Database.CONFIG.EMPTY) as db_ro: + _, pathname = maildir.deliver() + db_ro.add(pathname) + + def test_reopen_ro(self, db, maildir): + db.reopen(mode = dbmod.Mode.READ_ONLY) + with pytest.raises(errors.ReadOnlyDatabaseError): + _, pathname = maildir.deliver() + db.add(pathname) + + def test_reopen_rw(self, db, maildir): + # release the write lock + db.close() + + with dbmod.Database(maildir.path, 'ro', + config=notmuch2.Database.CONFIG.EMPTY) as db: + _, pathname = maildir.deliver() + db.reopen(mode = dbmod.Mode.READ_WRITE) + db.add(pathname) + class TestMessages: def test_add_message(self, db, maildir): |
