forked from bn222/cluster-deployment-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_clustersConfig.py
67 lines (52 loc) · 1.73 KB
/
test_clustersConfig.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
import dataclasses
import os
import pytest
import typing
import clustersConfig
@dataclasses.dataclass(frozen=True)
class TFileConfig:
filename: str
check: typing.Optional[
typing.Callable[
["TFileConfig", clustersConfig.ClustersConfig],
None,
]
] = None
def get_filepath(*components: str) -> str:
return os.path.join(os.path.dirname(__file__), *components)
def _test_parse_1(tfile: TFileConfig) -> None:
yamlpath = get_filepath(tfile.filename)
cc = clustersConfig.ClustersConfig(
yamlpath,
secrets_path="/secrets/path",
test_only=True,
)
assert isinstance(cc, clustersConfig.ClustersConfig)
assert isinstance(cc.hosts, list)
assert all(isinstance(host, clustersConfig.HostConfig) for host in cc.hosts)
if tfile.check is not None:
tfile.check(tfile, cc)
def check_test5(tfile: TFileConfig, cc: clustersConfig.ClustersConfig) -> None:
assert sorted(h.name for h in cc.hosts) == [
'...',
'foo',
'localhost',
'mycluster-worker-1',
]
TFILES = (
TFileConfig("tests/configs/test1.yaml"),
TFileConfig("tests/configs/test2.yaml"),
TFileConfig("tests/configs/test3.yaml"),
TFileConfig("tests/configs/test4.yaml"),
TFileConfig("tests/configs/test5.yaml", check_test5),
TFileConfig("tests/configs/test6.yaml"),
TFileConfig("tests/configs/test7.yaml"),
TFileConfig("tests/configs/test8.yaml"),
TFileConfig("tests/configs/test9.yaml"),
TFileConfig("tests/configs/test10.yaml"),
TFileConfig("tests/configs/test11.yaml"),
TFileConfig("microshift.yml"),
)
@pytest.mark.parametrize("tfile", TFILES)
def test_parse_1(tfile: TFileConfig) -> None:
_test_parse_1(tfile)