-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsnapshot.py
46 lines (36 loc) · 1.81 KB
/
snapshot.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
from pathlib import Path
from pulp_docs.main import PulpDocs, Config
def snapshot_fixture(fixture_dir: Path, repolist: Path, target: Path) -> Path:
"""Builds snapshot of the fixture-docs using @fixture_dir and @repolist at @target.
The snapshot should be taken after someone carefully inspect the core elements of
the site looks as expected, like:
* Navigation display: nav items that should and shouldnt be there.
* Special pages behave as expected, like RestAPI, Changes and index pages.
* Regular pages exists (or dont exist) where expected inside plugins and sections.
The snapshot is not intended to provide a 1:1 comparision, but more of a structural
comparision, so at least we catch obivous structural regressions.
Params:
fixture_dir: A dir which should contain `{repository_name}/{repository_tree}`
repolist: A yaml file containing the aggregation config.
target: Dir where to write the build.
Returns:
The Path of the new snapshot. The dirname is commit hash at the moment of the
which snapshot.
"""
# Guards to avoid surprises
if not fixture_dir.is_dir():
raise ValueError(f"'fixture_dir' should be a dir: {fixture_dir}")
if not list(fixture_dir.iterdir()):
raise ValueError(f"'fixture_dir' should NOT be empty.: {fixture_dir}")
if not target.is_dir():
raise ValueError(f"'fixture_dir' should be a dir: {target}")
if list(fixture_dir.iterdir()):
raise ValueError(f"'target' must be empty.: {target}")
if repolist.suffix not in (".yml", "yaml"):
raise ValueError(f"'repolist' must be a YAML file: {repolist.name}")
# TODO: test this.
config = Config()
config.repolist = repolist.absolute()
pulp_docs = PulpDocs(config)
pulp_docs.build(target=target)
return Path()