mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-05-06 05:03:49 +00:00
The issue appears in case if versions ar the same (e.g. rebuild); in this case printer doesn't increment version as builder does. Also util has been renamed to utils, keeping backward compatibiltiy
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from pathlib import Path
|
|
|
|
from ahriman.core.utils import walk
|
|
|
|
|
|
def test_test_coverage() -> None:
|
|
"""
|
|
must have test files for each source file
|
|
"""
|
|
root = Path()
|
|
for source_file in filter(lambda fn: fn.suffix == ".py" and fn.name != "__init__.py", walk(root / "src")):
|
|
# some workaround for well known files
|
|
if source_file.parts[2:4] == ("application", "handlers") and source_file.name != "handler.py":
|
|
filename = f"test_handler_{source_file.name}"
|
|
elif source_file.parts[2:4] == ("web", "views"):
|
|
if (api := source_file.parts[4]) == "api":
|
|
filename = f"test_view_{api}_{source_file.name}"
|
|
elif (version := source_file.parts[4]) in ("v1", "v2"):
|
|
api = source_file.parts[5]
|
|
filename = f"test_view_{version}_{api}_{source_file.name}"
|
|
elif source_file.name.endswith("_guard.py"):
|
|
filename = f"test_{source_file.name}"
|
|
else:
|
|
filename = f"test_view_{source_file.name}"
|
|
else:
|
|
filename = f"test_{source_file.name}"
|
|
|
|
test_file = Path("tests", *source_file.parts[1:-1], filename)
|
|
assert test_file.is_file(), test_file
|