-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests and canonicalization for ConfigWorkflow (#89)
* add doctest infra * add tests for `ConfigWorkflow` (creation from yaml / API) * add `CanonicalWorkflow` with - additional validation and information from outside yaml file - conversion function from `ConfigWorkflow` - unit tests * update `sirocco.workflow` to use `CanonicalWorkflow` * basic `workflow.Workflow` creation from `CanonicalWorkflow` test
- Loading branch information
Showing
9 changed files
with
185 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pathlib | ||
|
||
from sirocco import pretty_print | ||
from sirocco.core import workflow | ||
from sirocco.parsing import _yaml_data_models as models | ||
|
||
|
||
def test_minimal_workflow(): | ||
minimal_config = models.CanonicalWorkflow( | ||
name="minimal", | ||
rootdir=pathlib.Path("minimal"), | ||
cycles=[models.ConfigCycle(some_cycle={"tasks": []})], | ||
tasks=[models.ConfigShellTask(some_task={"plugin": "shell"})], | ||
data=models.ConfigData( | ||
available=[models.ConfigAvailableData(foo={})], | ||
generated=[models.ConfigGeneratedData(bar={})], | ||
), | ||
parameters={}, | ||
) | ||
|
||
testee = workflow.Workflow(minimal_config) | ||
|
||
pretty_print.PrettyPrinter().format(testee) | ||
|
||
assert len(list(testee.tasks)) == 0 | ||
assert len(list(testee.cycles)) == 1 | ||
assert testee.data[("foo", {})].available |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pathlib | ||
import textwrap | ||
|
||
from sirocco.parsing import _yaml_data_models as models | ||
|
||
|
||
def test_workflow_canonicalization(): | ||
config = models.ConfigWorkflow( | ||
name="testee", | ||
cycles=[models.ConfigCycle(minimal={"tasks": [models.ConfigCycleTask(a={})]})], | ||
tasks=[{"some_task": {"plugin": "shell"}}], | ||
data=models.ConfigData( | ||
available=[models.ConfigAvailableData(foo={})], | ||
generated=[models.ConfigGeneratedData(bar={})], | ||
), | ||
) | ||
|
||
testee = models.canonicalize_workflow(config, rootdir=pathlib.Path("foo")) | ||
assert testee.data_dict["foo"].name == "foo" | ||
assert testee.data_dict["bar"].name == "bar" | ||
assert testee.task_dict["some_task"].name == "some_task" | ||
|
||
|
||
def test_load_workflow_config(tmp_path): | ||
minimal_config = textwrap.dedent( | ||
""" | ||
cycles: | ||
- minimal: | ||
tasks: | ||
- a: | ||
tasks: | ||
- b: | ||
plugin: shell | ||
data: | ||
available: | ||
- c: | ||
generated: | ||
- d: | ||
""" | ||
) | ||
minimal = tmp_path / "minimal.yml" | ||
minimal.write_text(minimal_config) | ||
testee = models.load_workflow_config(str(minimal)) | ||
assert testee.name == "minimal" | ||
assert testee.rootdir == tmp_path |