def test_5(self): r1 = Client() assert r1.publish("newtoto", "hello") == False # nobody is subscribing that r2 = Client() assert r2.subscribe("newtoto") == True assert r1.publish("newtoto", "hello") == True assert r2.unsubscribe("newtoto") == True assert r2.get_event("newtoto") == None assert r1.publish("newtoto", "hello") == False # nobody is subscribing that
def test_3(self): r = Client() assert r.subscribe("toto") == True assert r.publish("toto", 42) == True assert r.publish("toto", "hello") == True assert r.get_event("toto") == 42 assert r.get_event("toto") == "hello" assert r.get_event("toto") == None assert r.publish("toto", 99) == True assert r.unsubscribe("toto")
def test_4(self): r1 = Client() r2 = Client() assert r1.subscribe("toto") == True assert r2.publish("toto", 42) == True assert r2.publish("toto", "hello") == True assert r1.get_event("toto") == 42 assert r1.get_event("toto") == "hello" assert r1.get_event("toto") == None assert r2.publish("toto", 99) == True assert r1.get_event("toto") == 99 assert r1.get_event("toto") == None assert r1.unsubscribe("toto")
def test_events_multi_clients(self): r1 = Client() r2 = Client() rp = Client() assert r1.subscribe("mychannel") assert r2.subscribe("mychannel") assert rp.publish("mychannel", "hello") assert r1.get_event("mychannel") == "hello" assert r1.unsubscribe("mychannel") assert r1.get_event("mychannel") == None assert r2.get_event("mychannel") == "hello"