ni / measurement-plugin-python

Python framework to develop measurement plug-ins for NI application software. Contains sample measurement plug-ins for InstrumentStudio and TestStand.
MIT License
19 stars 15 forks source link

test_decoder.py and test_encoder.py test cases have invalid default values #825

Closed bkeryan closed 3 months ago

bkeryan commented 3 months ago

Bug Report

Some of the test_decoder.py and test_encoder.py test cases fail if we change ParameterMetadata.initialize to always validate the default value type.

Repro or Code Sample

In ParameterMetadata.initialize, change

        if validate_type:
            _validate_default_value_type(parameter_metadata)

to

        _validate_default_value_type(parameter_metadata)

Expected Behavior

Tests still pass.

Current Behavior

Float/double array tests fail because they contain ints, also see #824

FAILED tests/unit/test_decoder.py::test___serializer___deserialize_parameter___successful_deserialization[values0] - TypeError: Unexpected type <class 'int'> in the default value for 'float_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_decoder.py::test___empty_buffer___deserialize_parameters___returns_zero_or_empty - TypeError: Unexpected type <class 'int'> in the default value for 'float_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_encoder.py::test___serializer___serialize_parameter___successful_serialization[test_values0] - TypeError: Unexpected type <class 'int'> in the default value for 'double_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_encoder.py::test___serializer___serialize_parameter___successful_serialization[test_values1] - TypeError: Unexpected type <class 'int'> in the default value for 'double_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_encoder.py::test___serializer___serialize_default_parameter___successful_serialization[default_values0] - TypeError: Unexpected type <class 'int'> in the default value for 'double_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_encoder.py::test___serializer___serialize_default_parameter___successful_serialization[default_values1] - TypeError: Unexpected type <class 'int'> in the default value for 'double_array_data'. Expected type: <class 'float'>.
FAILED tests/unit/test_encoder.py::test___serialize_parameter_multiple_times___returns_one_message_type[test_values0] - TypeError: Unexpected type <class 'int'> in the default value for 'double_array_data'. Expected type: <class 'float'>.

DoubleXYData tests fail too:

FAILED tests/unit/test_decoder.py::test___serializer___deserialize_parameter___successful_deserialization[values0] - TypeError: Unexpected type <class 'ni.protobuf.types.xydata_pb2.DoubleXYData'> in the default value for 'xy_data'. ...
FAILED tests/unit/test_decoder.py::test___empty_buffer___deserialize_parameters___returns_zero_or_empty - TypeError: Unexpected type <class 'ni.protobuf.types.xydata_pb2.DoubleXYData'> in the default value for 'xy_data'. ...

@dixonjoel Is DoubleXYData supported for configurations? Or only outputs?

Possible Solution

Float/double: see #824

DoubleXYData: not sure.

Context

This came up during the code review for #807

Your Environment

AB#2819853

dixonjoel commented 3 months ago

@bkeryan We haven't made any effort to support DoubleXYData for inputs so I'm not surprised this fails.