Skip to content

Commit 62eedbf

Browse files
committed
add test for compressed payload from template
1 parent a58eaa0 commit 62eedbf

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

tests/dataconverter/test_validation.py

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,52 @@ def test_validate_data_dict(data_dict, error_messages, caplog, request):
27072707
],
27082708
id="reserved-prefix",
27092709
),
2710+
pytest.param(
2711+
alter_dict(
2712+
TEMPLATE,
2713+
"/ENTRY[my_entry]/NXODD_name[nxodd_name]/float_value",
2714+
{"compress": np.float32(2.0), "strength": 4},
2715+
),
2716+
[],
2717+
id="appdef-compressed-payload",
2718+
),
2719+
pytest.param(
2720+
alter_dict(
2721+
TEMPLATE,
2722+
"/ENTRY[my_entry]/NXODD_name[nxodd_name]/float_value",
2723+
{"compress": np.bool_(True), "strength": 3},
2724+
),
2725+
[
2726+
"The value at /my_entry/nxodd_name/float_value "
2727+
"should be one of the following Python types: "
2728+
"(<class 'float'>, <class 'numpy.floating'>), as defined in the "
2729+
"NXDL as NX_FLOAT."
2730+
],
2731+
id="appdef-compressed-payload-wrong-type",
2732+
),
2733+
pytest.param(
2734+
alter_dict(
2735+
TEMPLATE,
2736+
"/ENTRY[my_entry]/SAMPLE[sample1]]/changer_position",
2737+
{"compress": np.int64(2), "strength": 2},
2738+
),
2739+
[],
2740+
id="baseclass-compressed-payload",
2741+
),
2742+
pytest.param(
2743+
alter_dict(
2744+
TEMPLATE,
2745+
"/ENTRY[my_entry]/SAMPLE[sample1]]/changer_position",
2746+
{"compress": np.float32(2.0), "strength": 3},
2747+
),
2748+
[
2749+
"The value at /my_entry/sample1/changer_position "
2750+
"should be one of the following Python types: "
2751+
"(<class 'int'>, <class 'numpy.integer'>), as defined in the "
2752+
"NXDL as NX_INT."
2753+
],
2754+
id="baseclass-compressed-payload-wrong-type",
2755+
),
27102756
],
27112757
)
27122758
def test_validate_nexus_file(data_dict, error_messages, caplog, tmp_path, request):
@@ -2845,6 +2891,6 @@ def test_validate_cli(caplog, cli_inputs, error_messages):
28452891
else:
28462892
with caplog.at_level(logging.INFO):
28472893
result = runner.invoke(validate_cli, cli_inputs)
2848-
# assert len(caplog.records) == len(error_messages)
2849-
# for expected_message, rec in zip(error_messages, caplog.records):
2850-
# assert expected_message == format_error_message(rec.message)
2894+
assert len(caplog.records) == len(error_messages)
2895+
for expected_message, rec in zip(error_messages, caplog.records):
2896+
assert expected_message == format_error_message(rec.message)

0 commit comments

Comments
 (0)