Commits

Anonymous committed 261b6d4 Draft

plugin manager no longer singleton; keyword arguments in plugin instantiation

Comments (0)

Files changed (2)

araldo_redis/endpoints/redis_endpoint.py

             :param config: configuration object
             :param gevent_queue: queue for forwarding incoming messages
         """
-        name = kwargs["name"]
+        print ">>>>>>>>>",kwargs
         config = kwargs["config"]
         gevent_queue = kwargs["gevent_queue"]
         redis_server = kwargs.get("redis_server", None)
             self._server = redis_server
         self._client = self._server.pubsub()
         self._client.subscribe(self._channel_name)
-        InBoundBase.__init__(self, name, config, gevent_queue)
+        InBoundBase.__init__(self, **kwargs)
 
     @staticmethod
     def plugin_id():
     """
     def __init__(self, **kwargs):
         name = kwargs["name"]
+        plugin_manager = kwargs["plugin_manager"]
         config = kwargs["config"]
         self._channel_name = config["channel"] 
         self._server = redis.Redis(
             host=config["host"], 
             port=config["port"])
-        OutBoundBase.__init__(self, name, config)
+        OutBoundBase.__init__(self, **kwargs)
 
     @staticmethod
     def plugin_id():

test/redis_test.py

 
 
 @pytest.fixture
+def plugin_manager():
+    return Mock()
+
+
+@pytest.fixture
 def queue():
     return Queue()
 
 
 @pytest.fixture
-def inbound(config, queue, redis_mock):
+def inbound(plugin_manager, config, queue, redis_mock):
     return redis_endpoint.InBound(
         name="redis_1",
+        plugin_manager=plugin_manager,
         config=config,
         gevent_queue=queue,
         redis_server=redis_mock)
 
 
 @pytest.fixture
-def outbound(config, redis_mock):
+def outbound(plugin_manager, config, redis_mock):
     with patch.object(redis_endpoint.redis, "Redis", redis_mock):
         return redis_endpoint.OutBound(
             name="redis_1",
+            plugin_manager=plugin_manager,
             config=config)
 
 
     assert redis_endpoint.InBound.plugin_id() == "inbound-redis"
 
 
-def test_check_connection_problem(config, queue):
+def test_check_connection_problem(plugin_manager, config, queue):
     redis_mock = Mock()
 
     def f():
     redis_mock.echo.side_effect = f
     end_point = redis_endpoint.InBound(
         name="redis_1",
+        plugin_manager=plugin_manager,
         config=config,
         gevent_queue=queue,
         redis_server=redis_mock)