Commit 219b9f42 authored by francisco.moreno.external@atos.net's avatar francisco.moreno.external@atos.net
Browse files

Minor changes in the test_unitary.py

parent fb20f8f6
Loading
Loading
Loading
Loading
+28 −28
Original line number Diff line number Diff line
@@ -400,34 +400,34 @@ def test_get_device_events(context_client_grpc: ContextClient, # pylint: disabl

    events_collector.stop()

def test_listen_events(monitoring_client: MonitoringClient,
    context_client_grpc: ContextClient,  # pylint: disable=redefined-outer-name
    context_db_mb: Tuple[Database, MessageBroker]):

    LOGGER.warning('test_listen_events begin')

    context_database = context_db_mb[0]

    # ----- Clean the database -----------------------------------------------------------------------------------------
    context_database.clear_all()

    # ----- Initialize the EventsCollector -----------------------------------------------------------------------------
    events_collector = EventsDeviceCollector(context_client_grpc,monitoring_client)
    events_collector.start()

    # # ----- Dump state of database before create the object ------------------------------------------------------------
    db_entries = context_database.dump()
    LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries)))
    for db_entry in db_entries:
        LOGGER.info('  [{:>4s}] {:40s} :: {:s}'.format(*db_entry)) # pragma: no cover
    LOGGER.info('-----------------------------------------------------------')
    assert len(db_entries) == 0

    populate('localhost', GRPC_PORT_CONTEXT) # place this call in the appropriate line, according to your tests

    kpi_id_list = events_collector.listen_events()

    assert bool(kpi_id_list) == True
# def test_listen_events(monitoring_client: MonitoringClient,
#     context_client_grpc: ContextClient,  # pylint: disable=redefined-outer-name
#     context_db_mb: Tuple[Database, MessageBroker]):
#
#     LOGGER.warning('test_listen_events begin')
#
#     context_database = context_db_mb[0]
#
#     # ----- Clean the database -----------------------------------------------------------------------------------------
#     context_database.clear_all()
#
#     # ----- Initialize the EventsCollector -----------------------------------------------------------------------------
#     events_collector = EventsDeviceCollector(context_client_grpc,monitoring_client)
#     events_collector.start()
#
#     # # ----- Dump state of database before create the object ------------------------------------------------------------
#     db_entries = context_database.dump()
#     LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries)))
#     for db_entry in db_entries:
#         LOGGER.info('  [{:>4s}] {:40s} :: {:s}'.format(*db_entry)) # pragma: no cover
#     LOGGER.info('-----------------------------------------------------------')
#     assert len(db_entries) == 0
#
#     populate('localhost', GRPC_PORT_CONTEXT) # place this call in the appropriate line, according to your tests
#
#     kpi_id_list = events_collector.listen_events()
#
#     assert bool(kpi_id_list) == True

def test_socket_ports(address, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)