Commit 5eb00ac5 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Monitoring component:

- Fixed unitary tests
parent b40be8a6
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -226,6 +226,18 @@ def ingestion_data(kpi_id_int):
                                  kpi_value)
        sleep(0.1)

##################################################
# Prepare Environment, should be the first test
##################################################

def test_prepare_environment(
    context_client : ContextClient,                 # pylint: disable=redefined-outer-name,unused-argument
):
    context_id = json_context_id(DEFAULT_CONTEXT_NAME)
    context_client.SetContext(Context(**json_context(DEFAULT_CONTEXT_NAME)))
    context_client.SetTopology(Topology(**json_topology(DEFAULT_TOPOLOGY_NAME, context_id=context_id)))


###########################
# Tests Implementation
###########################
@@ -601,10 +613,6 @@ def test_listen_events(
    events_collector = EventsDeviceCollector(metrics_db.name_mapping)
    events_collector.start()

    context_id = json_context_id(DEFAULT_CONTEXT_NAME)
    context_client.SetContext(Context(**json_context(DEFAULT_CONTEXT_NAME)))
    context_client.SetTopology(Topology(**json_topology(DEFAULT_TOPOLOGY_NAME, context_id=context_id)))

    LOGGER.info('Adding Device {:s}'.format(DEVICE_DEV1_UUID))
    device_with_connect_rules = copy.deepcopy(DEVICE_DEV1)
    device_with_connect_rules['device_config']['config_rules'].extend(DEVICE_DEV1_CONNECT_RULES)
@@ -629,11 +637,17 @@ def test_listen_events(
    assert len(kpi_id_list) > 0

    device_client.DeleteDevice(response)
    events_collector.stop()

    LOGGER.warning('test_listen_events end')


##################################################
# Cleanup Environment, should be the last test
##################################################
def test_cleanup_environment(
    context_client : ContextClient,                 # pylint: disable=redefined-outer-name,unused-argument
):
    context_id = json_context_id(DEFAULT_CONTEXT_NAME)
    context_client.RemoveTopology(TopologyId(**json_topology_id(DEFAULT_TOPOLOGY_NAME, context_id=context_id)))
    context_client.RemoveContext(ContextId(**context_id))

    events_collector.stop()

    LOGGER.warning('test_listen_events end')