Add qa command entrypoints
This commit is contained in:
parent
f3f4badaa2
commit
e796e09d14
4 changed files with 111 additions and 5 deletions
67
tests/test_qa.py
Normal file
67
tests/test_qa.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import tomllib
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from repub.qa import qa_entrypoint, qa_final_entrypoint
|
||||
|
||||
|
||||
def test_pyproject_registers_qa_scripts() -> None:
|
||||
pyproject_path = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
||||
config = tomllib.loads(pyproject_path.read_text(encoding="utf-8"))
|
||||
|
||||
scripts = config["project"]["scripts"]
|
||||
|
||||
assert scripts["qa"] == "repub.qa:qa_entrypoint"
|
||||
assert scripts["qa-final"] == "repub.qa:qa_final_entrypoint"
|
||||
|
||||
|
||||
def test_qa_entrypoint_runs_expected_commands_in_order(monkeypatch) -> None:
|
||||
recorded: list[tuple[str, ...]] = []
|
||||
|
||||
def fake_run(command: tuple[str, ...], *, check: bool) -> SimpleNamespace:
|
||||
recorded.append(command)
|
||||
return SimpleNamespace(returncode=0)
|
||||
|
||||
monkeypatch.setattr("repub.qa.subprocess.run", fake_run)
|
||||
|
||||
assert qa_entrypoint() == 0
|
||||
assert recorded == [
|
||||
(
|
||||
"tailwindcss",
|
||||
"-i",
|
||||
"./repub/static/app.tailwind.css",
|
||||
"-o",
|
||||
"./repub/static/app.css",
|
||||
),
|
||||
("black", "repub/", "tests/"),
|
||||
("flake8", "repub/", "tests/"),
|
||||
("pyright",),
|
||||
("pytest",),
|
||||
]
|
||||
|
||||
|
||||
def test_qa_final_entrypoint_runs_expected_commands_in_order(monkeypatch) -> None:
|
||||
recorded: list[tuple[str, ...]] = []
|
||||
|
||||
def fake_run(command: tuple[str, ...], *, check: bool) -> SimpleNamespace:
|
||||
recorded.append(command)
|
||||
return SimpleNamespace(returncode=0)
|
||||
|
||||
monkeypatch.setattr("repub.qa.subprocess.run", fake_run)
|
||||
|
||||
assert qa_final_entrypoint() == 0
|
||||
assert recorded == [
|
||||
(
|
||||
"tailwindcss",
|
||||
"-i",
|
||||
"./repub/static/app.tailwind.css",
|
||||
"-o",
|
||||
"./repub/static/app.css",
|
||||
),
|
||||
("black", "repub/", "tests/"),
|
||||
("flake8", "repub/", "tests/"),
|
||||
("pyright",),
|
||||
("pytest",),
|
||||
("nix", "fmt"),
|
||||
("nix", "flake", "check"),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue