qsirecon.utils.testing module

Class and utilities for testing the workflows module

class qsirecon.utils.testing.TestWorkflow(methodName='runTest')[source]

Bases: TestCase

Subclass for tests within the workflow module.

Invoke tests with python -m unittest discover test.

assertIsAlmostExpectedWorkflow(expected_name, expected_interfaces, expected_inputs, expected_outputs, actual)[source]

somewhat hacky way to confirm workflows are as expected, but with low confidence

assertIsSubsetOfList(expecteds, actuals)[source]
assert_circular(workflow, circular_connections)[source]

Check key paths in workflow by specifying connections that should induce circular paths (NetworkX error).

circular_connections is a list of tuples, for example:

[
    (
        "from_node_name",
        "to_node_name",
        ("from_node.output_field", "to_node.input_field"),
    ),
]
assert_inputs_set(workflow, additional_inputs={})[source]

Check mandatory inputs for nodes in the workflow (first level) are set.

Also checks keys in additional_inputs. An input counts as set if:

  • it is defined explicitly (e.g. in the interface declaration), or

  • it is connected to another node’s output (e.g. via workflow.connect).

additional_inputs maps node names to lists of field names, for example:

{"node_name": ["mandatory", "input", "fields"]}
get_inputs_outputs(nodes)[source]