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 100976DE020E for ; Tue, 1 May 2018 06:06:45 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, 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 2hOE_5fnFbML for ; Tue, 1 May 2018 06:06:43 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id B784C6DE01E7 for ; Tue, 1 May 2018 06:06:43 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1fDUzP-00047G-QT; Tue, 01 May 2018 09:06:39 -0400 Received: (nullmailer pid 9813 invoked by uid 1000); Tue, 01 May 2018 13:06:38 -0000 From: David Bremner To: Ruben Pollan , notmuch@notmuchmail.org Subject: Re: [PATCH] python: add bindings for notmuch_message_get_propert(y/ies) In-Reply-To: <20180427191527.13589-1-meskio@sindominio.net> References: <152485633339.1600.12264382495006409318@localhost> <20180427191527.13589-1-meskio@sindominio.net> Date: Tue, 01 May 2018 10:06:38 -0300 Message-ID: <87o9hzfrtt.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Tue, 01 May 2018 13:06:45 -0000 Ruben Pollan writes: > Message.get_property (prop) returns a string with the value of the property and > Message.get_properties (prop, exact=False) yields key, value pairs > --- > bindings/python/docs/source/message.rst | 4 ++ > bindings/python/notmuch/globals.py | 5 +++ > bindings/python/notmuch/message.py | 80 ++++++++++++++++++++++++++++++++- > 3 files changed, 88 insertions(+), 1 deletion(-) I started to write some simple tests for this, but I didn't get very far. running the test below, I get Traceback (most recent call last): File "", line 4, in File "/home/bremner/software/upstream/notmuch/bindings/python/notmuch/message.py", line 480, in get_property value = c_char_p("") TypeError: bytes or integer address expected instead of str instance diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh index 74b3f5a1..f7220565 100755 --- a/test/T610-message-property.sh +++ b/test/T610-message-property.sh @@ -89,6 +89,18 @@ testkey2 = NULL EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "msg.get_property (python)" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +msg = db.find_message("4EFC743A.3060609@april.org") +print("testkey1[1] = %s\n".format(msg.get_property("testkey1"))) +EOF +cat <<'EOF' > EXPECTED +testkey1[1] = testvalue1 +EOF +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "notmuch_message_remove_all_properties" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EXPECT0(notmuch_message_remove_all_properties (message, NULL));