2011-12-04 21:50:08 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description="python bindings"
|
2015-08-06 12:13:36 +03:00
|
|
|
. ./test-lib.sh || exit 1
|
2011-12-04 21:50:08 -04:00
|
|
|
|
2015-08-02 08:40:55 +02:00
|
|
|
test_require_external_prereq ${NOTMUCH_PYTHON}
|
|
|
|
|
2011-12-04 21:50:08 -04:00
|
|
|
add_email_corpus
|
|
|
|
|
|
|
|
test_begin_subtest "compare thread ids"
|
2011-12-07 10:46:17 +01:00
|
|
|
test_python <<EOF
|
2011-12-04 21:50:08 -04:00
|
|
|
import notmuch
|
2012-01-02 14:51:26 +00:00
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
2011-12-04 21:50:08 -04:00
|
|
|
q_new = notmuch.Query(db, 'tag:inbox')
|
2012-01-02 14:51:26 +00:00
|
|
|
q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
|
2011-12-04 21:50:08 -04:00
|
|
|
for t in q_new.search_threads():
|
2015-05-23 22:28:44 +02:00
|
|
|
print (t.get_thread_id())
|
2011-12-04 21:50:08 -04:00
|
|
|
EOF
|
2012-01-02 14:51:26 +00:00
|
|
|
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
|
2017-04-04 21:36:29 -03:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2012-01-02 14:51:27 +00:00
|
|
|
|
|
|
|
test_begin_subtest "compare message ids"
|
|
|
|
test_python <<EOF
|
|
|
|
import notmuch
|
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
|
|
|
q_new = notmuch.Query(db, 'tag:inbox')
|
|
|
|
q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
|
|
|
|
for m in q_new.search_messages():
|
2015-05-23 22:28:44 +02:00
|
|
|
print (m.get_message_id())
|
2012-01-02 14:51:27 +00:00
|
|
|
EOF
|
|
|
|
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
|
2017-04-04 21:36:29 -03:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2012-01-02 14:51:27 +00:00
|
|
|
|
2012-05-18 00:13:41 -04:00
|
|
|
test_begin_subtest "get non-existent file"
|
|
|
|
test_python <<EOF
|
|
|
|
import notmuch
|
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
2015-05-23 22:28:44 +02:00
|
|
|
print (db.find_message_by_filename("i-dont-exist"))
|
2012-05-18 00:13:41 -04:00
|
|
|
EOF
|
|
|
|
test_expect_equal "$(cat OUTPUT)" "None"
|
|
|
|
|
2017-03-09 14:32:28 +01:00
|
|
|
test_begin_subtest "get revision"
|
|
|
|
test_python ${MAIL_DIR} <<'EOF'
|
|
|
|
import notmuch
|
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
|
|
|
(revision, uuid) = db.get_revision()
|
|
|
|
print ("%s\t%lu" % (uuid, revision))
|
|
|
|
EOF
|
|
|
|
notmuch_uuid_sanitize < OUTPUT > CLEAN
|
|
|
|
cat <<'EOF' >EXPECTED
|
|
|
|
UUID 53
|
|
|
|
EOF
|
|
|
|
test_expect_equal_file EXPECTED CLEAN
|
|
|
|
|
|
|
|
grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT
|
|
|
|
|
|
|
|
test_begin_subtest "output of count matches test code"
|
|
|
|
notmuch count --lastmod '*' | cut -f2-3 > OUTPUT
|
|
|
|
test_expect_equal_file INITIAL_OUTPUT OUTPUT
|
|
|
|
|
2011-12-04 21:50:08 -04:00
|
|
|
test_done
|