Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 7, 2024
1 parent 9ff8ea1 commit 841bced
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/common/component_tests/run_and_check_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ def run_and_check_outputs(arguments, cmd):
clean_name = re.sub("^--", "", arg["name"])
new_arg["clean_name"] = clean_name


# use example to find test resource file
if arg["type"] == "file":
value = None
if arg["direction"] == "input":
value = f"{meta['resources_dir']}/{arg['example'][0]}"
example = arg.get("example")
if example:
if isinstance(example, list):
example = example[0]
value = f"{meta['resources_dir']}/{example}"
else:
example = arg.get("example", ["example"])[0]
ext_res = re.search(r"\.(\w+)$", example)
Expand All @@ -124,6 +130,9 @@ def run_and_check_outputs(arguments, cmd):
elif "test_default" in arg_info:
new_arg["value"] = arg_info["test_default"]

if arg["required"]:
assert new_arg.get("value") is not None, f"Argument '{clean_name}' is required but has no value"

arguments.append(new_arg)

fun_info = config["functionality"].get("info") or {}
Expand Down Expand Up @@ -154,6 +163,7 @@ def run_and_check_outputs(arguments, cmd):
value = arg["value"]
if arg["multiple"] and isinstance(value, list):
value = arg["multiple_sep"].join(value)
cmd.extend([arg["name"], str(value)])
if value:
cmd.extend([arg["name"], str(value)])

run_and_check_outputs(argset_args, cmd)

0 comments on commit 841bced

Please sign in to comment.