Skip to content

Commit 10b1c44

Browse files
committed
Fix tests
1 parent d761f37 commit 10b1c44

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/dataconverter/test_helpers.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ def fixture_filled_test_data(template, tmp_path):
195195
TEMPLATE["required"]["/ENTRY[my_entry]/NXODD_name[nxodd_name]/char_value"] = (
196196
"just chars" # pylint: disable=E1126
197197
)
198+
TEMPLATE["required"]["/ENTRY[my_entry]/OPTIONAL_group[my_group]/required_field"] = 1 # pylint: disable=E1126
198199
TEMPLATE["required"]["/ENTRY[my_entry]/definition"] = "NXtest" # pylint: disable=E1126
199200
TEMPLATE["required"]["/ENTRY[my_entry]/definition/@version"] = "2.4.6" # pylint: disable=E1126
200201
TEMPLATE["required"]["/ENTRY[my_entry]/program_name"] = "Testing program" # pylint: disable=E1126
201202
TEMPLATE["required"]["/ENTRY[my_entry]/NXODD_name[nxodd_name]/type"] = "2nd type" # pylint: disable=E1126
202203
TEMPLATE["required"]["/ENTRY[my_entry]/NXODD_name[nxodd_name]/date_value"] = (
203204
"2022-01-22T12:14:12.05018+00:00" # pylint: disable=E1126
204205
)
206+
TEMPLATE["optional"]["/ENTRY[my_entry]/OPTIONAL_group[my_group]/optional_field"] = 1
205207
TEMPLATE["optional"]["/ENTRY[my_entry]/required_group/description"] = (
206208
"An example description"
207209
)
@@ -352,15 +354,24 @@ def fixture_filled_test_data(template, tmp_path):
352354
id="atleast-one-required-child-not-provided-optional-parent",
353355
),
354356
pytest.param(
355-
alter_dict(
356-
TEMPLATE, "/ENTRY[my_entry]/OPTIONAL_group[my_group]/optional_field", 1
357+
set_to_none_in_dict(
358+
TEMPLATE,
359+
"/ENTRY[my_entry]/OPTIONAL_group[my_group]/required_field",
360+
"required",
361+
),
362+
(
363+
"The data entry, /ENTRY[my_entry]/OPTIONAL_group[my_group]/optional_field, has an "
364+
"optional parent, /ENTRY[entry]/OPTIONAL_group[optional_group], with required children set"
365+
". Either provide no children for /ENTRY[entry]/OPTIONAL_group[optional_group] or provide "
366+
"all required ones."
357367
),
358-
(""),
359368
id="required-field-not-provided-in-variadic-optional-group",
360369
),
361370
pytest.param(
362-
alter_dict(
363-
TEMPLATE, "/ENTRY[my_entry]/OPTIONAL_group[my_group]/required_field", 1
371+
set_to_none_in_dict(
372+
TEMPLATE,
373+
"/ENTRY[my_entry]/OPTIONAL_group[my_group]/optional_field",
374+
"required",
364375
),
365376
(""),
366377
id="required-field-provided-in-variadic-optional-group",
@@ -448,6 +459,7 @@ def test_validate_data_dict(
448459
elif request.node.callspec.id in (
449460
"wrong-enum-choice",
450461
"atleast-one-required-child-not-provided-optional-parent",
462+
"required-field-not-provided-in-variadic-optional-group",
451463
):
452464
with caplog.at_level(logging.WARNING):
453465
helpers.validate_data_dict(template, data_dict, nxdl_root)

0 commit comments

Comments
 (0)