mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 08:19:23 +00:00
Add pubsub event system and integrate sync notifications
This commit is contained in:
28
src/tests/test_pubsub.py
Normal file
28
src/tests/test_pubsub.py
Normal file
@@ -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