-
Notifications
You must be signed in to change notification settings - Fork 1
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 #18 from rpm-software-management/add-cache-and-tests
Add cache and tests
- Loading branch information
Showing
8 changed files
with
373 additions
and
96 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: Check that the cached aliases are up to date | ||
|
||
on: | ||
schedule: | ||
- cron: "44 4 */2 * *" | ||
pull_request: | ||
|
||
jobs: | ||
cache_check: | ||
name: Check the cached constant | ||
runs-on: "ubuntu-latest" | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
|
||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pypoetry/virtualenvs | ||
key: poetry-${{ hashFiles('poetry.lock') }} | ||
|
||
- run: sudo pipx install poetry | ||
env: | ||
PIPX_BIN_DIR: /usr/bin | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- name: Run the test checking the cache | ||
run: poetry run pytest -vv -k cache_up_to_date |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "opensuse-distro-aliases" | ||
version = "0.1.3" | ||
version = "0.2.0" | ||
description = "Aliases for active openSUSE releases" | ||
authors = ["Dan Čermák <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -17,6 +17,7 @@ mypy = ">=1.10" | |
ruff = ">=0.5" | ||
twine = ">=5.1" | ||
types-requests = ">=2.25" | ||
pytest = ">=8.3.2" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
|
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
Empty file.
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,41 @@ | ||
from typing import Set | ||
|
||
from opensuse_distro_aliases import CACHED_ACTIVE_DISTRIBUTION_ALIASES | ||
from opensuse_distro_aliases import Distro | ||
from opensuse_distro_aliases import get_distro_aliases | ||
|
||
|
||
def test_cache_up_to_date() -> None: | ||
# remove the version field from Tumbleweed, we don't want to precache that | ||
# value | ||
current_version = get_distro_aliases() | ||
for _, distros in current_version.items(): | ||
for i, distri in enumerate(distros): | ||
if distri.name == "openSUSE Tumbleweed": | ||
kwargs = distri.__dict__ | ||
kwargs["version"] = "" | ||
distros[i] = Distro(**kwargs) | ||
|
||
assert current_version == CACHED_ACTIVE_DISTRIBUTION_ALIASES | ||
|
||
|
||
def test_distro_aliases_without_eol() -> None: | ||
for _, distros in get_distro_aliases(include_eol=False).items(): | ||
for distri in distros: | ||
assert distri.active | ||
|
||
|
||
def test_distro_aliases_with_eol_includes_all_active_ones() -> None: | ||
all_distris = get_distro_aliases(include_eol=True) | ||
active_distris = get_distro_aliases(include_eol=False) | ||
|
||
assert set(all_distris.keys()) == set(active_distris.keys()) | ||
|
||
for distro_group in all_distris: | ||
cur_distro_group: Set[Distro] = set(all_distris[distro_group]) | ||
active_distro_group: Set[Distro] = set(active_distris[distro_group]) | ||
|
||
assert active_distro_group.issubset(cur_distro_group) | ||
|
||
for eol_distro in cur_distro_group.difference(active_distro_group): | ||
assert not eol_distro.active |