init
This commit is contained in:
65
backend/tests/test_artefakte.py
Normal file
65
backend/tests/test_artefakte.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""Artefakt-Schicht: Merge, ergaenze-anker, Writer, Prüfungs-Gerüst."""
|
||||
from pathlib import Path
|
||||
|
||||
import artefakte
|
||||
|
||||
FRAG_A = """## a.py::eins
|
||||
beschreibung: Erste.
|
||||
input: x
|
||||
output: y
|
||||
|
||||
## a.py::zwei
|
||||
beschreibung: Zweite.
|
||||
"""
|
||||
|
||||
FRAG_NACHFASS = """ergaenze-anker: a.py::_helfer zu a.py::eins
|
||||
|
||||
## a.py::drei
|
||||
beschreibung: Dritte.
|
||||
"""
|
||||
|
||||
|
||||
def test_merge_mit_nachfass():
|
||||
rumpf = artefakte.merge_fragmente([FRAG_A, FRAG_NACHFASS])
|
||||
assert rumpf.index("## a.py::eins") < rumpf.index("## a.py::zwei") < rumpf.index("## a.py::drei")
|
||||
assert "anker: a.py::_helfer" in rumpf.split("## a.py::zwei")[0] # im eins-Block
|
||||
assert "ergaenze-anker" not in rumpf
|
||||
|
||||
|
||||
def test_merge_dubletten_fallen_weg():
|
||||
rumpf = artefakte.merge_fragmente([FRAG_A, FRAG_A])
|
||||
assert rumpf.count("## a.py::eins") == 1
|
||||
|
||||
|
||||
def test_einheiten_datei_und_stand():
|
||||
text = artefakte.einheiten_datei("a.py", "## a.py::eins\nbeschreibung: X.", "abc123")
|
||||
assert text.startswith("# Einheiten: a.py\nstand: abc123\n")
|
||||
assert artefakte.lese_stand(text) == "abc123"
|
||||
|
||||
|
||||
def test_alle_ids():
|
||||
text = "## a.py::eins\nanker: a.py::_helfer\n\n## a.py::zwei\n"
|
||||
assert artefakte.alle_ids(text) == {"a.py::eins", "a.py::_helfer", "a.py::zwei"}
|
||||
|
||||
|
||||
def test_datei_pfad():
|
||||
assert artefakte.datei_pfad("backend/kanban.py") == "einheiten/backend__kanban.py.md"
|
||||
|
||||
|
||||
def test_schreibe_planer(tmp_path):
|
||||
pfade = artefakte.schreibe_planer(tmp_path, {"kern.md": "# Kern\n",
|
||||
"einheiten/a.py.md": "# Einheiten: a.py\n"})
|
||||
assert (tmp_path / ".planer" / "kern.md").read_text() == "# Kern\n"
|
||||
assert len(pfade) == 2
|
||||
|
||||
|
||||
def test_pruefung_geruest_mit_makefile(tmp_path):
|
||||
(tmp_path / "Makefile").write_text("test:\n\tpytest\ndev:\n\tuvicorn\n")
|
||||
text = artefakte.pruefung_geruest(tmp_path, "demo")
|
||||
assert "tests: make test" in text and "start: make dev" in text
|
||||
assert "lint: (keins vorhanden)" in text
|
||||
|
||||
|
||||
def test_pruefung_geruest_ohne_alles(tmp_path):
|
||||
text = artefakte.pruefung_geruest(tmp_path, "demo")
|
||||
assert "tests: (keins vorhanden)" in text
|
||||
Reference in New Issue
Block a user