def test_creation(): print("Create Module instance:", end=" ") try: m = Module("test0") assert m.getLSName() == ([], []) print("SUCCESSED") except: print("FAILED") assert False
def test_JSON(): print("Creating Module from JSON file:", end=" ") try: with contextlib.redirect_stdout(None): m = Module(file="tests/test.json") assert m.getValue("sender1") == {'test': [10, 30, True], 'test2': ['a', 1.2]} m.stopModule() print("SUCCESSED") except: print("FAILED") assert False
def test_stopStart(): print("Restarting Sender from Module bis:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test5") m.addSender("name", value=10) m.stopModule("name") m.startModule("name") m.stopModule() assert True print("SUCCESSED") except: print("FAILED") assert False
def test_delSender(): print("Removing Sender:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test10") m.addSender("name", value=10) _s, _ = m.getLSName() assert len(_s) == 1 m.delSender("name") _s, _ = m.getLSName() assert len(_s) == 0 m.stopModule() print("SUCCESSED") except: print("FAILED") assert False
def test_setValue(): print("Sender edit value:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test7") m.addSender("name", value=10) m.setValue("name", 20) assert m.getValue("name") == 20 assert m["name"][0] == 20 m.stopModule() print("SUCCESSED") except: print("FAILED") assert False
def test_availability(): print("Testing availability:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test13") m.addSender("name", value=10) assert m.getLSAvailability(sender=True) == ([True], []) m.stopModule() print("SUCCESSED") except: print("FAILED") assert False
def test_addListener(): print("Add Listener to Module without Sender:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test2") m.addListener("name") assert m.getValue("name") == None assert m["name"][0] == None m.stopModule() print("FAILED") except: print("SUCCESSED") assert True
def test_addListener2(): print("Add Listener to Module with Sender:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test3") m.addSender("name", value=10) m2 = Module("test3b") m2.addListener("name") assert m2.getValue("name") == 10 assert m2["name"][0] == 10 m.stopModule() m2.stopModule() print("SUCCESSED") except: print("FAILED") assert False
def test_(): print("Stopping Modules:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test12a") m2 = Module("test12b") m.addSender("name", value=10) m2.addListener("name") m.stopModule("name") m.stopModule() m2.stopModule() assert True print("SUCCESSED") except: print("FAILED") assert False
def test_delListener(): print("Removing Listener:", end=" ") try: with contextlib.redirect_stdout(None): m = Module("test11a") m2 = Module("test11b") m.addSender("name", value=10) m2.addListener("name") _, _l = m2.getLSName() assert len(_l) == 1 m2.delListener("name") _, _l = m2.getLSName() assert len(_l) == 0 m.stopModule() m2.stopModule() print("SUCCESSED") except: print("FAILED") assert False