-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from uclahs-cds/nwiltsie-regression-tests
Add regression tests for changelog text manipulation
- Loading branch information
Showing
15 changed files
with
305 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
python-version: | ||
- "3.9" | ||
- "3.10" | ||
- "3.12" | ||
|
||
steps: | ||
|
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
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
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
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,60 @@ | ||
"""Local plugin to parametrize tests from a JSON file.""" | ||
|
||
import json | ||
import datetime | ||
|
||
from collections import namedtuple | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
ChangelogUpdate = namedtuple( | ||
"ChangelogUpdate", ("original", "version", "expected", "url", "date") | ||
) | ||
|
||
# Named stash keys for storing the ChangelogUpdate objects between hook calls | ||
changelog_updates_key = pytest.StashKey[list[ChangelogUpdate]]() | ||
|
||
|
||
def pytest_configure(config: pytest.Config) -> None: | ||
"""Configure plugin by loading the Changelog data.""" | ||
resource_path = Path(__file__).resolve().parent.joinpath("resources") | ||
changelogs_file = resource_path / "changelogs.json" | ||
with changelogs_file.open(mode="r", encoding="utf-8") as infile: | ||
changelog_groups = json.load(infile) | ||
|
||
updates = [] | ||
for group in changelog_groups: | ||
date = datetime.date.fromisoformat(group["date"]) | ||
|
||
updates.append( | ||
ChangelogUpdate( | ||
resource_path / group["original"], | ||
None, | ||
resource_path / group["formatted"], | ||
group["url"], | ||
date, | ||
) | ||
) | ||
|
||
for version, expected in group.get("bumps", {}).items(): | ||
updates.append( | ||
ChangelogUpdate( | ||
resource_path / group["original"], | ||
version, | ||
resource_path / expected, | ||
group["url"], | ||
date, | ||
) | ||
) | ||
|
||
config.stash[changelog_updates_key] = updates | ||
|
||
|
||
def pytest_generate_tests(metafunc: pytest.Metafunc): | ||
"""Inject parameters for the 'changelog_update' fixture.""" | ||
if "changelog_update" in metafunc.fixturenames: | ||
metafunc.parametrize( | ||
"changelog_update", metafunc.config.stash[changelog_updates_key] | ||
) |
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,36 @@ | ||
# Changelog | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). | ||
|
||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [2.5.3] - 2024-05-05 | ||
|
||
### Security | ||
|
||
- Security item | ||
|
||
## [2.5.1] - 2024-02-01 | ||
|
||
### Added | ||
|
||
- Add one | ||
- Add two | ||
|
||
### Fixed | ||
|
||
- Fix one | ||
- Fix two | ||
|
||
## [2.5.0] - 2024-01-01 | ||
|
||
Stray text | ||
|
||
### Changed | ||
|
||
- Change one | ||
- Change two | ||
|
||
[2.5.0]: https://github.com/foo/bar/releases/tag/v2.5.0 | ||
[2.5.1]: https://github.com/foo/bar/compare/v2.5.0...v2.5.1 | ||
[2.5.3]: https://github.com/foo/bar/compare/v2.5.1...v2.5.3 |
Oops, something went wrong.