From 87cbdd9fb8cfaf1317e06f1f0605f164e1709d44 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 10 Aug 2022 09:01:54 -0400 Subject: [PATCH] Common: Rename subscribe_all() -> subscribe_all_events() --- monkey/common/event_queue/i_event_queue.py | 2 +- monkey/common/event_queue/pypubsub_event_queue.py | 5 +++-- .../common/event_queue/test_pypubsub_event_queue.py | 2 +- vulture_allowlist.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/common/event_queue/i_event_queue.py b/monkey/common/event_queue/i_event_queue.py index ae9371ba4..1c7334c34 100644 --- a/monkey/common/event_queue/i_event_queue.py +++ b/monkey/common/event_queue/i_event_queue.py @@ -10,7 +10,7 @@ class IEventQueue(ABC): """ @abstractmethod - def subscribe_all(self, subscriber: Callable[[AbstractEvent], None]): + def subscribe_all_events(self, subscriber: Callable[[AbstractEvent], None]): """ Subscribes a subscriber to all events diff --git a/monkey/common/event_queue/pypubsub_event_queue.py b/monkey/common/event_queue/pypubsub_event_queue.py index ff98a85f3..7f56b1162 100644 --- a/monkey/common/event_queue/pypubsub_event_queue.py +++ b/monkey/common/event_queue/pypubsub_event_queue.py @@ -1,8 +1,9 @@ from typing import Callable -from common.events import AbstractEvent from pubsub.core import Publisher +from common.events import AbstractEvent + from .i_event_queue import IEventQueue INTERNAL_ALL_EVENT_TYPES_TOPIC = "internal_all_event_types" @@ -12,7 +13,7 @@ class PyPubSubEventQueue(IEventQueue): def __init__(self, pypubsub_publisher: Publisher): self._pypubsub_publisher = pypubsub_publisher - def subscribe_all(self, subscriber: Callable[[AbstractEvent], None]): + def subscribe_all_events(self, subscriber: Callable[[AbstractEvent], None]): self._pypubsub_publisher.subscribe( listener=subscriber, topicName=INTERNAL_ALL_EVENT_TYPES_TOPIC ) diff --git a/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py b/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py index bedaf0c44..b018c5d89 100644 --- a/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py +++ b/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py @@ -67,7 +67,7 @@ def test_subscribe_all(): def subscriber(event, topic=pub.AUTO_TOPIC): subscriber_calls.append(topic.getName()) - pypubsub_event_queue.subscribe_all(subscriber) + pypubsub_event_queue.subscribe_all_events(subscriber) pypubsub_event_queue.publish(EventType) assert len(subscriber_calls) == 1 diff --git a/vulture_allowlist.py b/vulture_allowlist.py index a533be1a9..29359dfe9 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -270,4 +270,4 @@ subscribe_type # common\event_queue\pypubsub_event_queue.py subscribe_tag # common\event_queue\pypubsub_event_queue.py publish # common\event_queue\pypubsub_event_queue.py PyPubSubEventQueue # common\event_queue\pypubsub_event_queue.py -subscribe_all_event_types # common\event_queue\pypubsub_event_queue.py +subscribe_all_events # common\event_queue\pypubsub_event_queue.py