2011-12-05 02:50:08 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description="python bindings"
|
2017-09-25 22:38:19 +02:00
|
|
|
. $(dirname "$0")/test-lib.sh || exit 1
|
2011-12-05 02:50:08 +01:00
|
|
|
|
2015-08-02 08:40:55 +02:00
|
|
|
test_require_external_prereq ${NOTMUCH_PYTHON}
|
|
|
|
|
2011-12-05 02:50:08 +01:00
|
|
|
add_email_corpus
|
|
|
|
|
|
|
|
test_begin_subtest "compare thread ids"
|
2011-12-07 10:46:17 +01:00
|
|
|
test_python <<EOF
|
2011-12-05 02:50:08 +01:00
|
|
|
import notmuch
|
2012-01-02 15:51:26 +01:00
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
2011-12-05 02:50:08 +01:00
|
|
|
q_new = notmuch.Query(db, 'tag:inbox')
|
2012-01-02 15:51:26 +01:00
|
|
|
q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
|
2011-12-05 02:50:08 +01:00
|
|
|
for t in q_new.search_threads():
|
2015-05-23 22:28:44 +02:00
|
|
|
print (t.get_thread_id())
|
2011-12-05 02:50:08 +01:00
|
|
|
EOF
|
2012-01-02 15:51:26 +01:00
|
|
|
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
|
2017-04-05 02:36:29 +02:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2012-01-02 15:51:27 +01: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 15:51:27 +01:00
|
|
|
EOF
|
|
|
|
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
|
2017-04-05 02:36:29 +02:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2012-01-02 15:51:27 +01:00
|
|
|
|
2012-05-18 06:13:41 +02: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 06:13:41 +02: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
|
2017-09-24 14:36:12 +02:00
|
|
|
add_message '[content-type]="text/plain; charset=iso-8859-2"' \
|
|
|
|
'[content-transfer-encoding]=8bit' \
|
|
|
|
'[subject]="ISO-8859-2 encoded message"' \
|
|
|
|
"[body]=$'Czech word tu\350\362\341\350\350\355 means pinguin\'s.'" # ISO-8859-2 characters are generated by shell's escape sequences
|
|
|
|
test_begin_subtest "Add ISO-8859-2 encoded message, call get_message_parts"
|
|
|
|
test_python <<EOF
|
|
|
|
import notmuch
|
|
|
|
db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
|
|
|
|
q_new = notmuch.Query(db, 'ISO-8859-2 encoded message')
|
|
|
|
for m in q_new.search_messages():
|
|
|
|
for mp in m.get_message_parts():
|
|
|
|
continue
|
|
|
|
print(m.get_message_id())
|
|
|
|
EOF
|
|
|
|
|
|
|
|
notmuch search --sort=oldest-first --output=messages "tučňáččí" | sed s/^id:// > EXPECTED
|
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2017-03-09 14:32:28 +01:00
|
|
|
|
2011-12-05 02:50:08 +01:00
|
|
|
test_done
|