Add render: template file set with token substitution
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Tests for rendering the project template."""
|
||||
|
||||
from new_python.render import DEFAULT_PYTHON, render
|
||||
|
||||
TEMPLATE_FILES = {
|
||||
".gitignore",
|
||||
"AGENTS.md",
|
||||
"Pipfile",
|
||||
"conftest.py",
|
||||
"hooks/pre-commit",
|
||||
"justfile",
|
||||
"pyproject.toml",
|
||||
}
|
||||
|
||||
TEMPLATE_TOKENS = ("{{PKG}}", "{{NAME}}", "{{PYVER}}")
|
||||
|
||||
|
||||
def test_render_substitutes_all_tokens_for_a_dashed_name():
|
||||
"""Rendering a dashed name derives the package and substitutes every token."""
|
||||
files = render("demo-project")
|
||||
|
||||
assert set(files) == TEMPLATE_FILES | {"demo_project/__init__.py"}
|
||||
assert files["demo_project/__init__.py"] == ""
|
||||
|
||||
justfile = files["justfile"]
|
||||
assert justfile.count("demo_project") == 7
|
||||
assert "{{args}}" in justfile
|
||||
|
||||
assert 'known_first_party = ["demo_project"]' in files["pyproject.toml"]
|
||||
assert files["AGENTS.md"].startswith("# demo-project\n")
|
||||
assert f'python_version = "{DEFAULT_PYTHON}"' in files["Pipfile"]
|
||||
|
||||
assert "Put the repo root on sys.path" in files["conftest.py"]
|
||||
assert "__pycache__/" in files[".gitignore"]
|
||||
assert "just ci" in files["hooks/pre-commit"]
|
||||
|
||||
for rel, content in files.items():
|
||||
for token in TEMPLATE_TOKENS:
|
||||
assert token not in content, f"{token} left unsubstituted in {rel}"
|
||||
Reference in New Issue
Block a user