From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id BE0A96DE0183 for ; Thu, 7 Dec 2017 03:47:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.608 X-Spam-Level: X-Spam-Status: No, score=-0.608 tagged_above=-999 required=5 tests=[AWL=-0.121, FREEMAIL_FROM=0.001, PP_MIME_FAKE_ASCII_TEXT=0.243, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TTqWnxPhTGJd for ; Thu, 7 Dec 2017 03:47:58 -0800 (PST) Received: from mout.web.de (mout.web.de [212.227.15.14]) by arlo.cworth.org (Postfix) with ESMTPS id A7DEE6DE009B for ; Thu, 7 Dec 2017 03:47:57 -0800 (PST) Received: from localhost ([78.53.227.28]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M8hdL-1fIblM1i0h-00wEF7; Thu, 07 Dec 2017 12:42:55 +0100 From: l-m-h@web.de To: notmuch@notmuchmail.org Cc: Lucas Hoffmann Subject: [PATCH 4/6] test: Add tests for new python bindings Date: Thu, 7 Dec 2017 12:40:49 +0100 Message-Id: <804d7820ff04cfb7c52b4eb966845587d546d240.1512646265.git.l-m-h@web.de> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: <8737am9w18.fsf@tethera.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.15.1" X-Provags-ID: V03:K0:FnJccLNLrqO1OfoU7zZOo1lnThwvkpon3X9w9xs7srqh/7FPAUp Gj0xC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ESuf8O8= X-Mailman-Approved-At: Thu, 07 Dec 2017 11:31:51 -0800 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2017 11:47:58 -0000 From: Lucas Hoffmann This is a multi-part message in MIME format. --------------2.15.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit The tests where adopted from the tests for the corresponding C functions in test/T590-libconfig.sh. --- test/T390-python.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) --------------2.15.1 Content-Type: text/x-patch; name="0004-test-Add-tests-for-new-python-bindings.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0004-test-Add-tests-for-new-python-bindings.patch" diff --git a/test/T390-python.sh b/test/T390-python.sh index a93a7f34..725a00c9 100755 --- a/test/T390-python.sh +++ b/test/T390-python.sh @@ -74,4 +74,72 @@ EOF notmuch search --sort=oldest-first --output=messages "tučňáččí" | sed s/^id:// > EXPECTED test_expect_equal_file EXPECTED OUTPUT +# TODO currently these tests for setting and getting config values are +# somewhat interdependent. This is because the config values stored in the +# database are not cleaned up after each test, so they remain there for the +# next test. The ./README file states that this can happen so it seems kind +# of ok. + +test_begin_subtest "set and get config values" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +db.set_config('testkey1', 'testvalue1') +db.set_config('testkey2', 'testvalue2') +v1 = db.get_config('testkey1') +v2 = db.get_config('testkey2') +print('testkey1 = ' + v1) +print('testkey2 = ' + v2) +EOF +cat <<'EOF' >EXPECTED +testkey1 = testvalue1 +testkey2 = testvalue2 +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "get_config_list with no match returns empty generator" +test_python <<'EOF' +import notmuch +db = notmuch.Database() +v = db.get_config_list('nonexistent') +print(list(v) == []) +EOF +test_expect_equal "$(cat OUTPUT)" "True" + +test_begin_subtest "get_config_list with no arguments returns all pairs" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +db.set_config("zzzafter", "afterval") +db.set_config("aaabefore", "beforeval") +v = db.get_config_list() +for index, keyval in enumerate(v): + key, val = keyval + print('{}: {} => {}'.format(index, key, val)) +EOF +cat <<'EOF' >EXPECTED +0: aaabefore => beforeval +1: testkey1 => testvalue1 +2: testkey2 => testvalue2 +3: zzzafter => afterval +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "get_config_list prefix is used to match keys" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +db.set_config('testkey1', 'testvalue1') +db.set_config('testkey2', 'testvalue2') +v = db.get_config_list('testkey') +for index, keyval in enumerate(v): + key, val = keyval + print('{}: {} => {}'.format(index, key, val)) +EOF +cat <<'EOF' >EXPECTED +0: testkey1 => testvalue1 +1: testkey2 => testvalue2 +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done --------------2.15.1--