Browse Source

tests: python: Change names of dummy home directories.

Release_3.0
Hartmut Goebel 2 months ago
parent
commit
56445d7765
3 changed files with 22 additions and 18 deletions
  1. +2
    -0
      .gitignore
  2. +14
    -13
      test/python_tests/setup_test.py
  3. +6
    -5
      test/python_tests/test_handshake.py

+ 2
- 0
.gitignore View File

@ -57,6 +57,8 @@ __pycache__
*.pyc
test/gtest_parallel.py
test/python_tests/test?
test/python_tests/dummyhome?
test/python_tests/common
test/pEp_test_home
test/TestDriver
test/local


+ 14
- 13
test/python_tests/setup_test.py View File

@ -34,7 +34,7 @@ def link_if_exists(dirname, arthome):
os.symlink(orig, dirname, True)
def create_own_identities(mydir, arthome, username):
def create_own_identities(mydir, arthome, addr, username):
"create own identities as part of the test setup"
os.environ["HOME"] = os.path.join(mydir, arthome)
@ -42,7 +42,7 @@ def create_own_identities(mydir, arthome, username):
import pEp
me = pEp.Identity()
me.address = arthome + "@peptest.ch"
me.address = addr + "@peptest.ch"
me.username = username
pEp.myself(me)
@ -57,7 +57,7 @@ def link_file(filename):
os.symlink(src, filename, False)
def create_home(mydir, arthome, username):
def create_home(mydir, arthome, addr, username):
"create an artificial home directory for testing"
os.chdir(mydir)
@ -72,7 +72,8 @@ def create_home(mydir, arthome, username):
link_if_exists(".local", arthome)
link_if_exists("Library", arthome) # this may exist on macOS
p = Process(target=create_own_identities, args=(mydir, arthome, username))
p = Process(target=create_own_identities,
args=(mydir, arthome, addr, username))
p.start()
p.join()
@ -83,20 +84,20 @@ def create_homes():
"create two artificial home directories for the two parties"
try:
os.stat("test1")
os.stat("dummyhome1")
except FileNotFoundError:
create_home(mydir, "test1", "Alice One")
create_home(mydir, "test2", "Bob Two")
create_home(mydir, "dummyhome1", "test1", "Alice One")
create_home(mydir, "dummyhome2", "test2", "Bob Two")
os.chdir(mydir);
os.makedirs("common", exist_ok=True) # common inbox for Sync tests
else:
while True:
try:
os.stat("test2/.ready")
except:
sleep(1)
else:
os.stat("dummyhome1/.ready")
os.stat("dummyhome2/.ready")
break
except:
sleep(0.01)
def remove_homes():
@ -104,8 +105,8 @@ def remove_homes():
contents"""
os.chdir(mydir)
shutil.rmtree("test1", ignore_errors=True)
shutil.rmtree("test2", ignore_errors=True)
shutil.rmtree("dummyhome1", ignore_errors=True)
shutil.rmtree("dummyhome2", ignore_errors=True)
shutil.rmtree("common", ignore_errors=True)
shutil.rmtree("__pycache__", ignore_errors=True)


+ 6
- 5
test/python_tests/test_handshake.py View File

@ -43,7 +43,7 @@ def test_handshake():
def process1():
print("process1 starting")
setup_gnupg("test1") ; import pEp
setup_gnupg("dummyhome1") ; import pEp
me = Me(ALICE)
you = You(BOB)
@ -53,7 +53,7 @@ def test_handshake():
msg.longmsg = "Message Text\n"
enc = msg.encrypt()
send_message("test2", str(enc))
send_message("dummyhome2", str(enc))
txt = wait_for_message()
enc = pEp.Message(txt)
@ -67,12 +67,13 @@ def test_handshake():
msg.longmsg = "Message Text complete\n"
enc = msg.encrypt()
send_message("test2", str(enc))
send_message("dummyhome2", str(enc))
print("process1 finishing")
def process2():
print("process2 starting")
setup_gnupg("test2") ; import pEp
setup_gnupg("dummyhome2") ; import pEp
me = Me(BOB)
you = You(ALICE)
@ -87,7 +88,7 @@ def test_handshake():
out.longmsg = "Text Back\n"
enc = out.encrypt()
send_message("test1", str(enc))
send_message("dummyhome1", str(enc))
txt = wait_for_message()
msg = pEp.Message(txt)


Loading…
Cancel
Save