forked from p34709852/monkey
Island: Rename IslandEventTopic.AGENT_{CONNECTED,REGISTERED}
This commit is contained in:
parent
371e495f17
commit
bed684d7d0
|
@ -5,7 +5,7 @@ from . import IslandEventSubscriber
|
||||||
|
|
||||||
|
|
||||||
class IslandEventTopic(Enum):
|
class IslandEventTopic(Enum):
|
||||||
AGENT_CONNECTED = auto()
|
AGENT_REGISTERED = auto()
|
||||||
CLEAR_SIMULATION_DATA = auto()
|
CLEAR_SIMULATION_DATA = auto()
|
||||||
RESET_AGENT_CONFIGURATION = auto()
|
RESET_AGENT_CONFIGURATION = auto()
|
||||||
SET_ISLAND_MODE = auto()
|
SET_ISLAND_MODE = auto()
|
||||||
|
|
|
@ -30,7 +30,7 @@ def setup_island_event_handlers(container: DIContainer):
|
||||||
def _subscribe_agent_registration_events(
|
def _subscribe_agent_registration_events(
|
||||||
island_event_queue: IIslandEventQueue, container: DIContainer
|
island_event_queue: IIslandEventQueue, container: DIContainer
|
||||||
):
|
):
|
||||||
topic = IslandEventTopic.AGENT_CONNECTED
|
topic = IslandEventTopic.AGENT_REGISTERED
|
||||||
|
|
||||||
island_event_queue.subscribe(topic, container.resolve(handle_agent_registration))
|
island_event_queue.subscribe(topic, container.resolve(handle_agent_registration))
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ def test_subscribe_publish__no_event_body(
|
||||||
topic=IslandEventTopic.CLEAR_SIMULATION_DATA, subscriber=event_queue_subscriber
|
topic=IslandEventTopic.CLEAR_SIMULATION_DATA, subscriber=event_queue_subscriber
|
||||||
)
|
)
|
||||||
|
|
||||||
event_queue.publish(topic=IslandEventTopic.AGENT_CONNECTED)
|
event_queue.publish(topic=IslandEventTopic.AGENT_REGISTERED)
|
||||||
event_queue.publish(topic=IslandEventTopic.CLEAR_SIMULATION_DATA)
|
event_queue.publish(topic=IslandEventTopic.CLEAR_SIMULATION_DATA)
|
||||||
event_queue.publish(topic=IslandEventTopic.RESET_AGENT_CONFIGURATION)
|
event_queue.publish(topic=IslandEventTopic.RESET_AGENT_CONFIGURATION)
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ def test_subscribe_publish__with_event_body(
|
||||||
|
|
||||||
event = "my event!"
|
event = "my event!"
|
||||||
my_callable = MyCallable()
|
my_callable = MyCallable()
|
||||||
event_queue.subscribe(topic=IslandEventTopic.AGENT_CONNECTED, subscriber=my_callable)
|
event_queue.subscribe(topic=IslandEventTopic.AGENT_REGISTERED, subscriber=my_callable)
|
||||||
|
|
||||||
event_queue.publish(topic=IslandEventTopic.AGENT_CONNECTED, event=event)
|
event_queue.publish(topic=IslandEventTopic.AGENT_REGISTERED, event=event)
|
||||||
event_queue.publish(topic=IslandEventTopic.CLEAR_SIMULATION_DATA)
|
event_queue.publish(topic=IslandEventTopic.CLEAR_SIMULATION_DATA)
|
||||||
event_queue.publish(topic=IslandEventTopic.RESET_AGENT_CONFIGURATION)
|
event_queue.publish(topic=IslandEventTopic.RESET_AGENT_CONFIGURATION)
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@ def test_keep_subscriber_in_scope(event_queue: IIslandEventQueue):
|
||||||
def subscribe():
|
def subscribe():
|
||||||
# fn will go out of scope after subscribe() returns.
|
# fn will go out of scope after subscribe() returns.
|
||||||
fn = MyCallable()
|
fn = MyCallable()
|
||||||
event_queue.subscribe(topic=IslandEventTopic.AGENT_CONNECTED, subscriber=fn)
|
event_queue.subscribe(topic=IslandEventTopic.AGENT_REGISTERED, subscriber=fn)
|
||||||
|
|
||||||
subscribe()
|
subscribe()
|
||||||
|
|
||||||
event_queue.publish(topic=IslandEventTopic.AGENT_CONNECTED)
|
event_queue.publish(topic=IslandEventTopic.AGENT_REGISTERED)
|
||||||
|
|
||||||
assert MyCallable.called
|
assert MyCallable.called
|
||||||
|
|
Loading…
Reference in New Issue