-
Notifications
You must be signed in to change notification settings - Fork 34
/
test_preflight_check.py
71 lines (52 loc) · 2.09 KB
/
test_preflight_check.py
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
import io
import os
from contextlib import redirect_stdout
from typing import Optional
from utils.preflight_check import main as preflight_check
def get_preflight_check_output(*args):
f = io.StringIO()
opened_url: Optional[str] = None
# Capture URLs that were opened.
def open_in_browser(url):
nonlocal opened_url
opened_url = url
current_folder = os.path.dirname(os.path.abspath(__file__))
config = os.path.join(current_folder, "fixtures/config.pytest.yml")
with redirect_stdout(f):
preflight_check([*args, "--config", config], open_in_browser)
return f.getvalue(), opened_url
def test_artifacts():
output, opened_url = get_preflight_check_output("--only", "artifacts")
assert "Artifacts" in output
assert "Task Commands" not in output
assert "Training config" not in output
assert "Visualization" not in output
assert "artifacts/parameters.yml" in output
assert not opened_url
def test_task_group():
output, opened_url = get_preflight_check_output("--only", "task_group")
assert "Artifacts" not in output
assert "Task Commands" in output
assert "Training config" not in output
assert "Visualization" not in output
assert "all-pipeline-en-ru-1" in output
assert not opened_url
def test_task_graph():
output, opened_url = get_preflight_check_output("--only", "graph")
assert "Artifacts" not in output
assert "Task Commands" not in output
assert "Training config" not in output
assert "Visualization" in output
assert "https://gregtatum.github.io/taskcluster-tools/" in output
assert not opened_url
def test_task_graph_open():
output, opened_url = get_preflight_check_output("--only", "graph", "--open_graph")
assert "Artifacts" not in output
assert "Task Commands" not in output
assert "Training config" not in output
assert "Visualization" in output
assert "The taskgraph structure was opened in TaskCluster tools" in output
assert (
"https://gregtatum.github.io/taskcluster-tools/?taskGraph=http%3A//localhost%3A"
in opened_url
)