Closed SystemsPurge closed 1 month ago
closes #288
I think it would be great if we can test the functionality of these fields too. @RCX112 Could you please implement a test that uses json
, ngsi
, payload
for mqttCustom
? An example can be found here https://github.com/RWTH-EBC/FiLiP/blob/7919664cad1d7ff3800724f819a7c9f43bd28a80/tests/clients/test_ngsi_v2_cb.py#L832
The following warning pops up "UserWarning: Field name "json" shadows an attribute in parent "Mqtt"" ( due to the json fields in MqttCustom and HttpCustom ). Since the Http/Mqtt models do not have an explicit json field, i take it this is coming from some field/property in the base model. Tried to circumvent the warning by the use of aliases which obviously did not work.
Not sure what model to specify for the json payload type, i just put a Dict[str, any] for now ( despite number/string being valid json , the orion manual specifies that it needs to be a JSON object and not an object of primitive type )
Any input on these two points is welcome.
@SystemsPurge When I implemented the HttpCustom model I also had the same warnings. I simply supressed them with the warnings library, because the json() method of pydantic is already outdated anyway:
import warnings
# The pydantic models still have a .json() function, but this method is deprecated.
warnings.filterwarnings("ignore", category=UserWarning,
message='Field name "json" shadows an attribute in parent "Http"')
warnings.filterwarnings("ignore", category=UserWarning,
message='Field name "json" shadows an attribute in parent "Mqtt"')
@djs0109 Which version of Orion do we currently use for the tests, because the custom notifications don't work for version 3.7 for example?
Hi @RCX112 , it should be Orion >= 3.8, I have tested with 3.8.1
The following warning pops up "UserWarning: Field name "json" shadows an attribute in parent "Mqtt"" ( due to the json fields in MqttCustom and HttpCustom ). Since the Http/Mqtt models do not have an explicit json field, i take it this is coming from some field/property in the base model. Tried to circumvent the warning by the use of aliases which obviously did not work.
Not sure what model to specify for the json payload type, i just put a Dict[str, any] for now ( despite number/string being valid json , the orion manual specifies that it needs to be a JSON object and not an object of primitive type )
Any input on these two points is welcome.