Skip to content

Commit fe9c41b

Browse files
committed
added test
1 parent 0b87d6f commit fe9c41b

File tree

1 file changed

+29
-0
lines changed
  • packages/dask-task-models-library/tests/container_tasks

1 file changed

+29
-0
lines changed

packages/dask-task-models-library/tests/container_tasks/test_io.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,32 @@ def test_objects_are_compatible_with_dask_requirements(model_cls, model_cls_exam
184184
model_instance = model_cls.model_validate(example)
185185
reloaded_instance = loads(dumps(model_instance))
186186
assert reloaded_instance == model_instance
187+
188+
189+
def test_create_task_output_from_task_ignores_additional_entries(
190+
tmp_path: Path, faker: Faker
191+
):
192+
task_output_schema = TaskOutputDataSchema.model_validate(
193+
{
194+
"some_output_1": {
195+
"required": True,
196+
},
197+
"some_output_2": {
198+
"required": True,
199+
},
200+
}
201+
)
202+
output_file = _create_fake_outputs(task_output_schema, tmp_path, False, faker)
203+
assert output_file
204+
# Add more data to the output file to simulate additional entries
205+
file_path = tmp_path / output_file
206+
data = json.loads(file_path.read_text())
207+
data["extra_key"] = "extra_value"
208+
file_path.write_text(json.dumps(data))
209+
210+
task_output_data = TaskOutputData.from_task_output(
211+
schema=task_output_schema,
212+
output_folder=tmp_path,
213+
output_file_ext=output_file,
214+
)
215+
assert len(task_output_data) == 2, "Should only contain the expected keys"

0 commit comments

Comments
 (0)