Ejemplo n.º 1
0
 def setUp(self):
     super(AMQPDriverTestCase, self).setUp()
     self.user = "******"
     self.password = "******"
     self.credentials = config.Credentials(self.user, self.password)
     self.host = "host"
     self.conf = config.ConnectionConfig(self.host, self.credentials)
     self.driver = driver.AMQPDriver(self.conf)
Ejemplo n.º 2
0
 def test_driver_uses_pika_sync_engine(self):
     """
     Tests that driver uses sync amqp engine if async_engine parameter=False
      in config object
     """
     conf = config.ConnectionConfig(self.host, self.credentials)
     drvr = driver.AMQPDriver(conf)
     self.assertEqual(drvr._engine, pika_sync)
Ejemplo n.º 3
0
    def test_get_writer_for_sync_engine(self, engine_mock):
        """
        Tests that driver uses Writer of sync engine
        """

        conf = config.ConnectionConfig(self.host, self.credentials)
        drvr = driver.AMQPDriver(conf)
        writer = drvr.create_writer()
        self.assertEqual(writer, engine_mock())
Ejemplo n.º 4
0
    def test_get_reader_for_sync_engine(self, engine_mock):
        """
        Tests that driver uses Reader of sync engine
        """

        conf = config.ConnectionConfig(self.host, self.credentials)
        drvr = driver.AMQPDriver(conf)
        queue = "queue_name"
        preprocessor = mock.Mock()
        reader = drvr.create_reader(queue, preprocessor)
        self.assertEqual(reader, engine_mock())
Ejemplo n.º 5
0
    def test_publish_message_via_existing_reader_sync(self, get_mock):
        """
        Tests that message is published via existing reader
        """
        conf = config.ConnectionConfig(self.host, self.credentials)
        drvr = driver.AMQPDriver(conf)
        drvr._reader = mock.MagicMock()
        exchange = "exchange_name"
        routing_key = "rk"
        message = mock.MagicMock()

        drvr.publish_message(exchange, routing_key, message)
        get_mock().publish_message.assert_called_once_with(
            exchange, routing_key, message)
Ejemplo n.º 6
0
 def _get_driver(self):
     return driver.AMQPDriver(self._config)
Ejemplo n.º 7
0
 def _get_driver(self):
     if not self._config:
         raise exceptions.IncorrectAMQPConfig(ampq_url=self._config)
     driver = amqp_driver.AMQPDriver(self._config)
     return driver