mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
python: Remove find_message_by_filename workaround
Now that notmuch_database_find_message_by_filename works on read-only databases, remove the workaround that disabled it on read-write databases. This also adds a regression test for find_message_by_filename.
This commit is contained in:
parent
cdd698f969
commit
54508eb78d
2 changed files with 8 additions and 9 deletions
|
@ -526,19 +526,10 @@ class Database(object):
|
|||
retry.
|
||||
:raises: :exc:`NotInitializedError` if the database was not
|
||||
intitialized.
|
||||
:raises: :exc:`ReadOnlyDatabaseError` if the database has not been
|
||||
opened in read-write mode
|
||||
|
||||
*Added in notmuch 0.9*"""
|
||||
self._assert_db_is_initialized()
|
||||
|
||||
# work around libnotmuch calling exit(3), see
|
||||
# id:20120221002921.8534.57091@thinkbox.jade-hamburg.de
|
||||
# TODO: remove once this issue is resolved
|
||||
if self.mode != Database.MODE.READ_WRITE:
|
||||
raise ReadOnlyDatabaseError('The database has to be opened in '
|
||||
'read-write mode for get_directory')
|
||||
|
||||
msg_p = NotmuchMessageP()
|
||||
status = Database._find_message_by_filename(self._db, _str(filename),
|
||||
byref(msg_p))
|
||||
|
|
|
@ -28,4 +28,12 @@ EOF
|
|||
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
|
||||
test_expect_equal_file OUTPUT EXPECTED
|
||||
|
||||
test_begin_subtest "get non-existent file"
|
||||
test_python <<EOF
|
||||
import notmuch
|
||||
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
||||
print db.find_message_by_filename("i-dont-exist")
|
||||
EOF
|
||||
test_expect_equal "$(cat OUTPUT)" "None"
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue