-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathworkflow_integration_test.py
More file actions
148 lines (124 loc) · 4.56 KB
/
workflow_integration_test.py
File metadata and controls
148 lines (124 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
from unittest.mock import patch
import pytest
from structlog.testing import capture_logs
from exasol.toolbox.tools.workflow import CLI
class TestListWorkflows:
@staticmethod
def test_with_default(cli_runner):
result = cli_runner.invoke(CLI, ["list"])
assert result.exit_code == 0
assert result.output == (
"build-and-publish\n"
"cd\n"
"check-release-tag\n"
"checks\n"
"ci\n"
"dependency-update\n"
"gh-pages\n"
"matrix-all\n"
"matrix-exasol\n"
"matrix-python\n"
"merge-gate\n"
"pr-merge\n"
"report\n"
"slow-checks\n"
)
@staticmethod
def test_with_columns(cli_runner):
result = cli_runner.invoke(CLI, ["list", "--columns"])
assert result.exit_code == 0
assert "build-and-publish" in result.output
assert "cd" in result.output
assert "check-release-tag" in result.output
assert "checks" in result.output
assert "ci" in result.output
assert "dependency-update" in result.output
assert "gh-pages" in result.output
assert "matrix-all" in result.output
assert "matrix-exasol" in result.output
assert "matrix-python" in result.output
assert "merge-gate" in result.output
assert "pr-merge" in result.output
assert "report" in result.output
assert "slow-checks" in result.output
def test_show_workflow(cli_runner):
result = cli_runner.invoke(CLI, ["show", "checks"])
assert result.exit_code == 0
assert "name: Checks " in result.output
@pytest.mark.parametrize(
"workflow",
[
"build-and-publish",
"cd",
"check-release-tag",
"checks",
"ci",
"dependency-update",
"gh-pages",
"matrix-all",
"matrix-exasol",
"matrix-python",
"merge-gate",
"pr-merge",
"report",
"slow-checks",
],
)
def test_diff_workflow(cli_runner, tmp_path, workflow):
with capture_logs():
# set up with file in tmp_path so checks files are the same
cli_runner.invoke(CLI, ["install", workflow, str(tmp_path)])
result = cli_runner.invoke(CLI, ["diff", workflow, str(tmp_path)])
assert result.exit_code == 0
# as the files are the same, we expect no difference
assert result.output.strip() == ""
class TestInstallWorkflow:
@staticmethod
def test_all_workflows(cli_runner, tmp_path):
result = cli_runner.invoke(CLI, ["install", "all", str(tmp_path)])
all_files = sorted([filepath.name for filepath in tmp_path.iterdir()])
assert result.exit_code == 0
assert all_files == [
"build-and-publish.yml",
"cd.yml",
"check-release-tag.yml",
"checks.yml",
"ci.yml",
"dependency-update.yml",
"gh-pages.yml",
"matrix-all.yml",
"matrix-exasol.yml",
"matrix-python.yml",
"merge-gate.yml",
"pr-merge.yml",
"report.yml",
"slow-checks.yml",
]
assert (
f"Installed build-and-publish in \n{tmp_path}/build-and-publish.yml"
in result.output
)
@staticmethod
def test_install_twice_no_error(cli_runner, tmp_path):
cli_runner.invoke(CLI, ["install", "checks", str(tmp_path)])
result = cli_runner.invoke(CLI, ["install", "checks", str(tmp_path)])
all_files = sorted([filepath.name for filepath in tmp_path.iterdir()])
assert result.exit_code == 0
assert all_files == ["checks.yml"]
assert f"Installed checks in \n{tmp_path}/checks.yml" in result.output
class TestUpdateWorkflow:
@staticmethod
def test_when_file_does_not_previously_exist(cli_runner, tmp_path):
with capture_logs():
result = cli_runner.invoke(CLI, ["update", "checks", str(tmp_path)])
assert result.exit_code == 0
assert result.output.strip() == f"Updated checks in \n{tmp_path}/checks.yml"
@staticmethod
def test_with_existing_file(cli_runner, tmp_path):
# set up with file in tmp_path so checks files are the same
cli_runner.invoke(CLI, ["install", "checks", str(tmp_path)])
with patch("typer.confirm", return_value=False):
result = cli_runner.invoke(CLI, ["update", "checks", str(tmp_path)])
assert result.exit_code == 0
# files are identical, so no output expected
assert result.output.strip() == ""