adding a simplistic test
authorVolker Birk <vb@pep.foundation>
Fri, 05 Jan 2018 15:25:16 +0100
changeset 2351b59bc7d1baa3
parent 2350 4725d91aabeb
child 2352 c28e9e3c7fcb
adding a simplistic test
test/python_tests/test1.py
test/python_tests/test_setup.py
test/python_tests/transport.py
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/python_tests/test1.py	Fri Jan 05 15:25:16 2018 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +# -*- coding: utf-8 -*-
     1.5 +
     1.6 +# this file is under GNU General Public License 3.0
     1.7 +# Copyleft 2017, p≡p foundation
     1.8 +
     1.9 +
    1.10 +from transport import *
    1.11 +
    1.12 +
    1.13 +class Test1:
    1.14 +
    1.15 +    def setup_class(self):
    1.16 +        arthome = "test1"
    1.17 +
    1.18 +        self.mydir = os.path.abspath(os.path.curdir)
    1.19 +
    1.20 +        os.environ["HOME"] = os.path.join(self.mydir, arthome)
    1.21 +        os.environ["GNUPGHOME"] = os.path.join(self.mydir, arthome, '.gnupg')
    1.22 +
    1.23 +        os.chdir(os.path.join(self.mydir, arthome))
    1.24 +
    1.25 +    @property
    1.26 +    def me(self):
    1.27 +        # because of flaws of py.test these two lines are necessary
    1.28 +        assert os.environ["GNUPGHOME"] != ""
    1.29 +        import pEp
    1.30 +
    1.31 +        i = pEp.Identity()
    1.32 +        i.address = "test1@peptest.ch"
    1.33 +        i.username = "Alice One"
    1.34 +        pEp.myself(i)
    1.35 +        return i
    1.36 +
    1.37 +    @property
    1.38 +    def you(self):
    1.39 +        assert os.environ["GNUPGHOME"] != ""
    1.40 +        import pEp
    1.41 +
    1.42 +        i = pEp.Identity()
    1.43 +        i.address = "test2@peptest.ch"
    1.44 +        i.username = "Bob Two"
    1.45 +        pEp.update_identity(i)
    1.46 +        return i
    1.47 +
    1.48 +    def test_send_message(self):
    1.49 +        assert os.environ["GNUPGHOME"] != ""
    1.50 +        import pEp
    1.51 +
    1.52 +        msg = pEp.Message()
    1.53 +        msg.from_ = self.me
    1.54 +        msg.to = [self.you]
    1.55 +        msg.shortmsg = "Subject line"
    1.56 +        msg.longmsg = "Message Text\n"
    1.57 +
    1.58 +        enc = msg.encrypt()
    1.59 +        send_message("test2", str(enc))
    1.60 +
     2.1 --- a/test/python_tests/test_setup.py	Thu Jan 04 23:02:04 2018 +0100
     2.2 +++ b/test/python_tests/test_setup.py	Fri Jan 05 15:25:16 2018 +0100
     2.3 @@ -22,7 +22,6 @@
     2.4  
     2.5  realhome = os.path.expanduser("~")
     2.6  mydir = os.path.abspath(os.path.curdir)
     2.7 -files_to_link = ("transport.py",)
     2.8  
     2.9  
    2.10  def link_if_exists(dirname, arthome):
    2.11 @@ -64,8 +63,6 @@
    2.12      os.makedirs(arthome, exist_ok=True)
    2.13  
    2.14      os.chdir(arthome)
    2.15 -    for filename in files_to_link:
    2.16 -        link_file(filename)
    2.17  
    2.18      link_if_exists("bin", arthome)
    2.19      link_if_exists("include", arthome)
     3.1 --- a/test/python_tests/transport.py	Thu Jan 04 23:02:04 2018 +0100
     3.2 +++ b/test/python_tests/transport.py	Fri Jan 05 15:25:16 2018 +0100
     3.3 @@ -7,9 +7,6 @@
     3.4  """
     3.5  This module is implementing a basic message transport. Messages are written
     3.6  into the artificial home of the receiver and deleted when read.
     3.7 -
     3.8 -This module will be copied into the artificial home directories and used from
     3.9 -inside.
    3.10  """
    3.11  
    3.12