def main(): logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) connection_handler = ConnectionHandler() connection = connection_handler.get_connection() publisher = Producer(connection) for i in range(2): for message in data: queue = message['id'] now = datetime.now() str_now = now.isoformat() message['event_hour'] = str_now publisher.publish(queue, message) connection.sleep(0.1)
def main(): logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) connection_handler = ConnectionHandler() consumer = Consumer(connection_handler) consumer.start_working()
def test_init_app(self): connection_handler = ConnectionHandler() assert True == connection_handler._connection.is_open assert isinstance(connection_handler._connection, BlockingConnection) assert connection_handler._connection is not None
def test_close_connection(self): connection_handler = ConnectionHandler() connection_handler.close_connection() assert True == connection_handler._connection.is_closed
def test_get_connection(self): connection_handler = ConnectionHandler() assert True == connection_handler._connection.is_open assert connection_handler._connection is not None
def test_open_connection_with_bad_credentials(self): with pytest.raises(ProbableAuthenticationError): connection_handler = ConnectionHandler('localhost', 5672, 'toto', 'toto')
def test_open_connection_with_bad_port_number(self): with pytest.raises(ConnectionClosed): connection_handler = ConnectionHandler('localhost', 5555, 'guest', 'guest')