Browse Source

doc and test

master
Volker Birk 7 years ago
parent
commit
82030c72e3
  1. 2
      src/pEpmodule.cc
  2. 32
      test/basic_doctest.py

2
src/pEpmodule.cc

@ -251,7 +251,7 @@ BOOST_PYTHON_MODULE(pEp)
" flags 1 is force encryption\n"
)
.def("decrypt", &Message::decrypt,
"msg2, keys, rating, consumed, flags = msg1.decrypt()\n"
"msg2, keys, rating, flags = msg1.decrypt()\n"
"\n"
"decrypts a p≡p message and returns a tuple with data\n"
"\n"

32
test/basic_doctest.py

@ -1,21 +1,31 @@
"""
>>> from pEp import *
>>> m = outgoing_message(Identity("vb@dingens.org", "23", "Volker Birk"))
>>> m.to = [Identity("trischa@dingens.org", "42", "Patricia Bednar")]
>>> m.shortmsg = "Hello"
>>> m.longmsg = "Something\\n"
>>> import pEp
>>> me = pEp.Identity("alice.smith@peptest.ch", "23", "Alice Smith")
>>> me.username
'Alice Smith'
>>> print(me)
Alice Smith <alice.smith@peptest.ch>
>>> you = pEp.Identity("bob.bourne@peptest.ch", "42", "Bob Bourne")
>>> print(you)
Bob Bourne <bob.bourne@peptest.ch>
>>> m = pEp.outgoing_message(me)
>>> m.to = [you]
>>> m.shortmsg = "let's meet next week"
>>> m.longmsg = "Please call me back"
>>> print(str(m).replace('\\r', ''))
From: Volker Birk <vb@dingens.org>
To: Patricia Bednar <trischa@dingens.org>
Subject: Hello
From: Alice Smith <alice.smith@peptest.ch>
To: Bob Bourne <bob.bourne@peptest.ch>
Subject: let's meet next week
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="msg.txt"
<BLANKLINE>
Something
<BLANKLINE>
>>>
Please call me back
>>> m2 = m.encrypt()
>>> m3, keys, rating, flags = m2.decrypt()
>>> rating
6
"""
if __name__ == "__main__":

Loading…
Cancel
Save