Browse Source

end on notifications feature

master
Volker Birk 6 years ago
parent
commit
ee2ef4b4ba
  1. 17
      test/sync_handshake.py
  2. 20
      test/sync_test.py

17
test/sync_handshake.py

@ -47,6 +47,10 @@ SYNC_HANDSHAKE_ACCEPTED = 0
SYNC_HANDSHAKE_REJECTED = 1
the_end = False
end_on = (
pEp.sync_handshake_signal.SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED,
pEp.sync_handshake_signal.SYNC_NOTIFY_ACCEPTED_GROUP_CREATED
)
def print_msg(p):
@ -108,10 +112,7 @@ class UserInterface(pEp.UserInterface):
except NameError:
self.deliverHandshakeResult(SYNC_HANDSHAKE_ACCEPTED)
elif signal in (
pEp.sync_handshake_signal.SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED,
pEp.sync_handshake_signal.SYNC_NOTIFY_ACCEPTED_GROUP_CREATED
):
if signal in end_on:
global the_end
the_end = True
@ -157,10 +158,18 @@ if __name__=="__main__":
help="reject device group")
optParser.add_option("--accept", action="store_false", dest="reject",
help="accept device group (default)")
optParser.add_option("-E", "--end-on", dest="notifications",
help="end on these notifications")
options, args = optParser.parse_args()
if not options.exec_for:
options.exec_for = os.path.basename(os.getcwd())
if options.notifications:
end_on = eval(options.notifications)
try: None in end_on
except TypeError:
end_on = (end_on,)
run(options.exec_for, options.color)

20
test/sync_test.py

@ -20,14 +20,16 @@ import shutil
import pathlib
def test_for(path, color=None):
def test_for(path, color=None, end_on=None):
cwd = os.getcwd();
os.chdir(path)
os.environ["HOME"] = os.getcwd()
print("running tests for " + path)
from sync_handshake import run
run(path, color)
import sync_handshake
if end_on:
sync_handshake.end_on = end_on
sync_handshake.run(path, color)
os.chdir(cwd)
@ -85,6 +87,8 @@ if __name__ == "__main__":
help="setup environment, then stop")
optParser.add_option("-p", "--print", action="store_true", dest="print",
help="print sync message trace in inbox")
optParser.add_option("-E", "--end-on", dest="notifications",
help="end on these notifications")
options, args = optParser.parse_args()
if options.cleanall:
@ -139,8 +143,14 @@ if __name__ == "__main__":
setup("Laptop")
if not options.setup_only:
Phone = Process(target=test_for, args=("Phone", "red"))
Laptop = Process(target=test_for, args=("Laptop", "green"))
end_on = None
if options.notifications:
end_on = eval(options.notifications)
try: None in end_on
except TypeError:
end_on = (end_on,)
Phone = Process(target=test_for, args=("Phone", "red", end_on))
Laptop = Process(target=test_for, args=("Laptop", "green", end_on))
Phone.start()
Laptop.start()

Loading…
Cancel
Save