-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add html-snapshot testing with basic fixture
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
################ | ||
### PULPCORE ### | ||
################ | ||
# Minimal setup with pulpcore only. | ||
|
||
[[ pulpcore ]] | ||
|
||
path = 'pulpcore/CHANGES.md' | ||
data = ''' | ||
# Changelog | ||
## x.y.z (YYYY-MM-DD) | ||
#### Features | ||
- feature-changes-check | ||
#### Bugfixes | ||
- bugfixes-changes-check | ||
''' | ||
|
||
[[ pulpcore ]] | ||
|
||
path = 'pulpcore/index.md' | ||
data = ''' | ||
# Welcome to Pulpcore | ||
pulpcore-index-check | ||
''' | ||
|
||
[[ pulpcore ]] | ||
|
||
path = 'pulpcore/guides/guides1.md' | ||
data = ''' | ||
# Guide1 | ||
guide1-check | ||
''' | ||
|
||
[[ pulpcore ]] | ||
|
||
path = 'pulpcore/guides/guides2.md' | ||
|
||
data = ''' | ||
# Guide2 | ||
guide2-check | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pulp_docs.test_tools.snapshot import snapshot_fixture | ||
from pathlib import Path | ||
|
||
|
||
def test_snapshot_fixture(tmp_path): | ||
"""Test that using different fixture_dir or repolist the snapshot is different.""" | ||
fixture_dir = Path() | ||
target = Path() | ||
repolist = Path() | ||
dirname = snapshot_fixture(fixture_dir, repolist, target) |