You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filip will validate every entity in the returned list against 1) data value and type 2) unit specified as metadata. If any of this validation does not work, filip will abort and raise an error.
Expected behavior
Filip can give a warning, on what entity is failing the validation, and still return the rest valid entities.
To reproduce
importjsonimportrequestsfromfilip.clients.ngsi_v2importContextBrokerClientfromfilip.models.baseimportFiwareHeaderfromfilip.models.ngsi_v2importContextEntityfromfilip.utils.cleanupimportclear_context_brokerorion_url="http://...:1026"fiware_header=FiwareHeader(service="filip_374", service_path="/")
cbc=ContextBrokerClient(
url=orion_url,
fiware_header=fiware_header)
clear_context_broker(cb_client=cbc)
# Send bad entities to the Context Brokerentity_wrong_value_type= {
"id": "test:weather_station_1",
"type": "WeatherStation",
"temperature": {"type": "Number", "value": "Error"}
}
entity_wrong_unit= {
"id": "test:weather_station_2",
"type": "WeatherStation",
"temperature": {"type": "Number",
"value": 20,
"metadata":
{"unitCode":
{"type": "Text",
"value": "Error"}
}
}
}
headers= {
'fiware-service': 'filip_374',
'fiware-servicepath': '/',
'Content-Type': 'application/json'
}
forentityin [entity_wrong_value_type, entity_wrong_unit]:
payload=json.dumps(entity)
url=f"{orion_url}/v2/entities"response=requests.request("POST", url, headers=headers, data=payload)
print(response.text)
# send dummy valid entities to the Context Brokerentities_valid= [ContextEntity(id=f"test374:Entity:{i}", type="Test") foriinrange(10)]
cbc.update(entities=entities_valid, action_type="append")
# TODO the bad entities will block the whole requestentities=cbc.get_entity_list()
The text was updated successfully, but these errors were encountered:
Filip will validate every entity in the returned list against 1) data value and type 2) unit specified as metadata. If any of this validation does not work, filip will abort and raise an error.
Expected behavior
Filip can give a warning, on what entity is failing the validation, and still return the rest valid entities.
To reproduce
The text was updated successfully, but these errors were encountered: