From 39bada23f9538404141dbf34c7265f2bc4a5c751 Mon Sep 17 00:00:00 2001 From: bpinsard Date: Tue, 19 Mar 2024 10:58:34 -0400 Subject: [PATCH] add tests for assume_ready --- datalad_container/tests/test_run.py | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/datalad_container/tests/test_run.py b/datalad_container/tests/test_run.py index c3aa6e0..f628279 100644 --- a/datalad_container/tests/test_run.py +++ b/datalad_container/tests/test_run.py @@ -275,6 +275,56 @@ def test_extra_inputs(path=None): ] ) == set(runinfo.get("extra_inputs", set())) +@with_tree( + tree={ + "container.img": "image file", + "input.txt": "input data" + } +) +def test_assume_ready(path=None): + ds = Dataset(path).create(force=True, **common_kwargs) + ds.containers_add( + "mycontainer", + image="container.img", + call_fmt="echo image={img} cmd={cmd} img_dspath={img_dspath} img_dirpath={img_dirpath} > out.log", + **common_kwargs + ) + ds.save(**common_kwargs) + ds.containers_run( + "XXX", + container_name="mycontainer", + assume_ready=['image'], + **common_kwargs) + ok_file_has_content( + os.path.join(ds.repo.path, "out.log"), + "image=container.img", + re_=True, + ) + commit_msg = ds.repo.call_git(["show", "--format=%B"]) + cmd, runinfo = get_run_info(ds, commit_msg) + assert "container.img" not in runinfo.get("extra_inputs", []) + with pytest.raises(ValueError): + ds.containers_run( + "XXX", + inputs=['input.txt'], + container_name="mycontainer", + assume_ready=['inputsssstypo', 'outputs'], + **common_kwargs) + with pytest.raises(IncompleteResultsError): + ds.containers_run( + "XXX", + inputs=['input.txt'], + outputs=['out.log'], + container_name="mycontainer", + assume_ready=['inputs', 'outputs'], + **common_kwargs) + ds.containers_run( + "XXX", + inputs=['input.txt'], + outputs=['out.log'], + container_name="mycontainer", + assume_ready=['inputs'], + **common_kwargs) @skip_if_no_network @with_tree(tree={"subdir": {"in": "innards"}})