Exemple #1
0
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)
Exemple #2
0
def main():
    logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)

    connection_handler = ConnectionHandler()

    consumer = Consumer(connection_handler)
    consumer.start_working()
Exemple #3
0
 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
Exemple #4
0
 def test_close_connection(self):
     connection_handler = ConnectionHandler()
     connection_handler.close_connection()
     assert True == connection_handler._connection.is_closed
Exemple #5
0
 def test_get_connection(self):
     connection_handler = ConnectionHandler()
     assert True == connection_handler._connection.is_open
     assert connection_handler._connection is not None
Exemple #6
0
 def test_open_connection_with_bad_credentials(self):
     with pytest.raises(ProbableAuthenticationError):
         connection_handler = ConnectionHandler('localhost', 5672, 'toto',
                                                'toto')
Exemple #7
0
 def test_open_connection_with_bad_port_number(self):
     with pytest.raises(ConnectionClosed):
         connection_handler = ConnectionHandler('localhost', 5555, 'guest',
                                                'guest')