mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-13 16:21:42 +00:00
Add pubsub event system and integrate sync notifications
This commit is contained in:
1 parent
20dfc35f7e
commit
724c0b883f
4 files changed
+69
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
from seedpass.core.pubsub import PubSub
|
||||
|
||||
|
||||
def test_subscribe_and_publish():
|
||||
bus = PubSub()
|
||||
calls = []
|
||||
|
||||
def handler(arg):
|
||||
calls.append(arg)
|
||||
|
||||
bus.subscribe("event", handler)
|
||||
bus.publish("event", 123)
|
||||
|
||||
assert calls == [123]
|
||||
|
||||
|
||||
def test_unsubscribe():
|
||||
bus = PubSub()
|
||||
calls = []
|
||||
|
||||
def handler():
|
||||
calls.append(True)
|
||||
|
||||
bus.subscribe("event", handler)
|
||||
bus.unsubscribe("event", handler)
|
||||
bus.publish("event")
|
||||
|
||||
assert calls == []
|
||||
Reference in new issue
Block a user