def test_drain_buffer(self): """Tests draining the queue buffer""" # We insert a message into the buffer here. Running the function twice # ensures it is fully drained. queue = log_to_rabbitmq.RabbitMQ(self.parser) queue.buffer.put('test message') assert log_to_rabbitmq.drain_buffer(queue) assert log_to_rabbitmq.drain_buffer(queue)
def test_config(self): """Tests for proper handling of config elements""" # This may pass a channel error if the queue has already been declared # durable. That's a totally acceptable result. try: self.parser.set('rabbitmq', 'durable', 'True') self.parser.set('rabbitmq', 'auto_delete', 'True') self.parser.set('rabbitmq', 'refresh', 'None') self.parser.set('rabbitmq', 'queue', 'unittest') queue = log_to_rabbitmq.RabbitMQ(self.parser) assert queue.publish('test message') except ChannelError: return True try: self.parser.set('rabbitmq', 'durable', 'False') self.parser.set('rabbitmq', 'auto_delete', 'False') self.parser.set('rabbitmq', 'refresh', '10') self.parser.set('rabbitmq', 'queue', 'unittest') queue = log_to_rabbitmq.RabbitMQ(self.parser) assert queue.publish('test message') except ChannelError: return True
def test_publish(self): """Tests that we can publish to the queue""" logging.debug('Using host: ' + self.parser.get('rabbitmq', 'host')) queue = log_to_rabbitmq.RabbitMQ(self.parser) assert queue.publish('test message')
def test_refresh(self): """Tests the _refresh_connection method""" queue = log_to_rabbitmq.RabbitMQ(self.parser) queue.last_connect = 0 assert queue._refresh_connection() # pylint: disable=w0212
def test_name(self): """Tests that our AMQP class has names in it""" queue = log_to_rabbitmq.RabbitMQ(self.parser) assert queue.__name__ assert queue.__unicode__()