Skip to content

Commit e280fb8

Browse files
committed
Updated tests for pipelines
1 parent e76fd3a commit e280fb8

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

test/fixtures/pipeline_dag_test.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
All this stuff should be removed
6+
7+
## 0.0.1 (2022-01-01)
8+
9+
This stuff stays.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Changelog
2+
3+
## Unreleased (2022-01-06)
4+
5+
### Updates
6+
7+
- Chg: modified ``b`` xxx. [Alice](alice@example.com), [Charly](charly@example.com), [Juliet](juliet@example.com)
8+
9+
## 0.0.3 (2022-01-05)
10+
11+
### New
12+
13+
- New: add file ``e``, modified ``b``. [Bob](bob@example.com)
14+
This is a message body.
15+
16+
With multi-line content:
17+
- one
18+
- two
19+
20+
**bug:** #42
21+
22+
**change-id:** Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
23+
24+
**signed-off-by:** A. U. Thor <committer@example.com>
25+
26+
**cc:** R. E. Viewer <reviewer@example.com>
27+
28+
**subject:** This is a fake subject spanning to several lines
29+
as you can see
30+
31+
32+
- New: add file ``c``. [Charly](charly@example.com)
33+
34+
## 0.0.2 (2022-01-02)
35+
36+
### New
37+
38+
- Add ``b`` with non-ascii chars éèàâ§µ and html chars ``&<``. [Alice](alice@example.com)
39+
**change-id:** Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
40+
41+
42+
## 0.0.1 (2022-01-01)
43+
44+
### New
45+
46+
- New: first commit. [Bob](bob@example.com)

test/test_pipeline.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""Testing pipelines and actions."""
2+
from pathlib import Path
23

34
from clgen import pipeline
45

6+
FIXTURES_DIR = Path(__file__).parent / "fixtures"
7+
58

69
def test_action_builtin():
710
"""Actions run correctly."""
@@ -37,3 +40,47 @@ def test_pipeline_factory():
3740
pipe = pipeline.pipeline_factory(actions)
3841
assert pipe.run(" this is a bad idea. ") == "This is a bad idea."
3942
assert pipe.run() == "No commit message."
43+
44+
45+
def test_pipelline_dag():
46+
"""Make sure a typical DAG from YAML executes properly."""
47+
changelog_path = FIXTURES_DIR / "pipeline_dag_test.md"
48+
actions = [
49+
{
50+
"action": "AppendString",
51+
"comment": "Append the changelog from the last release heading on to the generated changelog",
52+
"kwargs": {
53+
"postfix": [
54+
{
55+
"action": "ReadFile",
56+
"comment": "Read the existing changelog",
57+
"kwargs": {"filename": str(changelog_path)},
58+
},
59+
{
60+
"action": "Slice",
61+
"comment": "Return just part of the file",
62+
"kwargs": {
63+
"start": [
64+
{
65+
"action": "ReadFile",
66+
"comment": "Read the existing changelog",
67+
"kwargs": {"filename": str(changelog_path)},
68+
},
69+
{
70+
"action": "FirstRegExMatchPosition",
71+
"comment": "Find the position of the last release heading",
72+
"kwargs": {
73+
"pattern": r"(?im)^## [0-9]+\.[0-9]+(?:\.[0-9]+)?\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)$"
74+
},
75+
},
76+
]
77+
},
78+
},
79+
]
80+
},
81+
},
82+
]
83+
pipe = pipeline.pipeline_factory(actions)
84+
input_text = "This is new\n"
85+
expected = input_text + "## 0.0.1 (2022-01-01)\n\nThis stuff stays.\n"
86+
assert pipe.run(input_text) == expected

0 commit comments

Comments
 (0)