From 77efd29e66ede28bf4015e87f1e6b05b3556adb1 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Wed, 23 Apr 2025 14:16:14 +0000 Subject: [PATCH] Common - Type Checkers - Assertions: - Corrected assertions for Endpoint --- src/common/type_checkers/Assertions.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/type_checkers/Assertions.py b/src/common/type_checkers/Assertions.py index f241dc0fb..cbe095396 100644 --- a/src/common/type_checkers/Assertions.py +++ b/src/common/type_checkers/Assertions.py @@ -15,6 +15,8 @@ import logging from typing import Callable, Dict +from common.tools.grpc.Tools import grpc_message_to_json_string + LOGGER = logging.getLogger(__name__) # ----- Enumerations --------------------------------------------------------------------------------------------------- @@ -472,7 +474,7 @@ def validate_topology(message, num_devices=None, num_links=None): def validate_endpoint(message): assert isinstance(message, dict) - assert len(message.keys()) == 6 + assert len(message.keys()) in {5, 6}, 'Wrong number of attributes: {:s}'.format(str(message)) assert 'endpoint_id' in message validate_endpoint_id(message['endpoint_id']) assert 'name' in message @@ -482,10 +484,14 @@ def validate_endpoint(message): assert 'kpi_sample_types' in message assert isinstance(message['kpi_sample_types'], list) for kpi_sample_type in message['kpi_sample_types']: validate_kpi_sample_types_enum(kpi_sample_type) - assert 'endpoint_location' in message - # TODO: validate "endpoint_location" - assert 'capabilities' in message - # TODO: validate "capabilities" + if 'endpoint_location' in message: + #assert 'endpoint_location' in message + # TODO: validate "endpoint_location" + pass + if 'capabilities' in message: + #assert 'capabilities' in message + # TODO: validate "capabilities" + pass def validate_component(component): assert isinstance(component, dict) -- GitLab