neutralize upstream service branding
This commit is contained in:
35
tests/test_branding.py
Normal file
35
tests/test_branding.py
Normal file
@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
FORBIDDEN_TOKEN = "ever" + "os"
|
||||
SKIPPED_PARTS = {
|
||||
".git",
|
||||
".pytest_cache",
|
||||
".venv",
|
||||
"__pycache__",
|
||||
"data",
|
||||
}
|
||||
|
||||
|
||||
def test_current_project_does_not_expose_upstream_product_name() -> None:
|
||||
matches: list[str] = []
|
||||
for path in PROJECT_ROOT.rglob("*"):
|
||||
relative = path.relative_to(PROJECT_ROOT)
|
||||
if any(part in SKIPPED_PARTS for part in relative.parts):
|
||||
continue
|
||||
if FORBIDDEN_TOKEN in path.name.lower():
|
||||
matches.append(f"filename: {relative}")
|
||||
if not path.is_file():
|
||||
continue
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
for line_number, line in enumerate(text.splitlines(), start=1):
|
||||
if FORBIDDEN_TOKEN in line.lower():
|
||||
matches.append(f"content: {relative}:{line_number}")
|
||||
|
||||
assert matches == []
|
||||
Reference in New Issue
Block a user