11import pytest
22from pathlib import Path
3+ import yaml
34
45from ..runner .pipeline import Pipeline
56from ..dataclasses .process_step import ProcessStep
@@ -23,6 +24,47 @@ class DummyProcessStep:
2324 pass
2425
2526
27+ @pytest .fixture
28+ def yaml_one_step ():
29+ return """
30+ name: one_step
31+ steps:
32+ multiply by xy:
33+ module: PoissonUncertainties
34+ step_id: 3
35+ requires_steps: []
36+ configuration:
37+ multiplier: 3
38+ signal: sample::signal
39+ io_sources:
40+ - sample
41+ """
42+
43+
44+ @pytest .fixture
45+ def yaml_linear_pipeline ():
46+ return """
47+ name: simple_pipeline
48+ steps:
49+ poisson:
50+ module: PoissonUncertainties
51+ step_id: 1
52+ another poisson:
53+ module: PoissonUncertainties
54+ step_id: 2
55+ requires_steps: [1]
56+ multiply by xy:
57+ module: PoissonUncertainties
58+ step_id: 3
59+ requires_steps: [2]
60+ configuration:
61+ multiplier: 3
62+ signal: sample::signal
63+ io_sources:
64+ - sample
65+ """
66+
67+
2668def test_linear_pipeline (linear_pipeline ):
2769 "tests the sequence is expected for a linear graph"
2870 pipeline = Pipeline (graph = linear_pipeline )
@@ -75,3 +117,16 @@ def test_diverging_branch_addition(
75117 pipeline .add_outgoing_branch (branch , branching_node )
76118 assert [* pipeline .static_order ()] == [1 , 2 , 3 , 6 , 5 ]
77119 assert pipeline .graph == {3 : {2 , 1 }, 2 : {1 }, 5 : {6 }, 6 : {2 }}
120+
121+
122+ def test_yaml_format (yaml_linear_pipeline ):
123+ yaml_obj = yaml .safe_load (yaml_linear_pipeline )
124+ assert "steps" in yaml_obj
125+ assert "poisson" in yaml_obj ["steps" ]
126+ assert type (yaml_obj ["steps" ]["multiply by xy" ]["configuration" ]) == dict
127+
128+
129+ def test_pipeline_from_yaml (yaml_one_step ):
130+ pipeline = Pipeline .from_yaml (yaml_one_step )
131+ assert pipeline .name == "one_step"
132+ assert type (pipeline ) == Pipeline
0 commit comments