der Lisp Omniflo Test verwendet jetzt wirklich alle existierenden Omniflo Teile die da sind.
This commit is contained in:
+11
-6
@@ -107,7 +107,7 @@
|
||||
;; exportiert CSV nach tests/output/.
|
||||
;; ============================================================
|
||||
(defun c:TEST_OMNIFLO (/ tests-json-pfad testfaelle
|
||||
x-pos x-schritt
|
||||
x-val y-val
|
||||
idx eintrag sivasnr hoehe-str drehung-str
|
||||
description insert-pt anzahl-ok anzahl-fehler
|
||||
results-list tests-out-dir old-results)
|
||||
@@ -148,8 +148,6 @@
|
||||
(princ "\n================================================================")
|
||||
|
||||
;; Alle Bloecke einfuegen
|
||||
(setq x-pos 0.0)
|
||||
(setq x-schritt 200.0)
|
||||
(setq anzahl-ok 0)
|
||||
(setq anzahl-fehler 0)
|
||||
(setq results-list nil)
|
||||
@@ -170,11 +168,18 @@
|
||||
)
|
||||
(setq description (omni:val eintrag "description"))
|
||||
|
||||
(setq insert-pt (list x-pos 0.0 (atof hoehe-str)))
|
||||
;; x,y-Koordinaten aus JSON lesen (wie in omniflo_uebersicht.dxf)
|
||||
(setq x-val (omni:val eintrag "x"))
|
||||
(setq y-val (omni:val eintrag "y"))
|
||||
(if (null x-val) (setq x-val 0.0))
|
||||
(if (null y-val) (setq y-val 0.0))
|
||||
(if (not (numberp x-val)) (setq x-val (atof x-val)))
|
||||
(if (not (numberp y-val)) (setq y-val (atof y-val)))
|
||||
(setq insert-pt (list x-val y-val (atof hoehe-str)))
|
||||
|
||||
(princ (strcat "\n " (itoa idx) ". "
|
||||
(if description description (if sivasnr sivasnr "?"))
|
||||
" -> (" (rtos x-pos 2 0) ", 0, " hoehe-str ")"))
|
||||
" -> (" (rtos x-val 2 0) ", " (rtos y-val 2 0) ", " hoehe-str ")"))
|
||||
|
||||
(if (omni:test-insert sivasnr insert-pt hoehe-str drehung-str)
|
||||
(progn
|
||||
@@ -193,9 +198,9 @@
|
||||
)
|
||||
)
|
||||
|
||||
(setq x-pos (+ x-pos x-schritt))
|
||||
)
|
||||
|
||||
|
||||
;; Zusammenfassung
|
||||
(princ "\n================================================================")
|
||||
(princ (strcat "\n Eingefuegt: " (itoa anzahl-ok)
|
||||
|
||||
+79
-1
@@ -22,7 +22,7 @@ sys.path.insert(0, _LIB_DIR)
|
||||
|
||||
from export_csv import (
|
||||
build_lookup, process_blocks, build_bogen_merkmale,
|
||||
build_weiche_merkmale, load_json
|
||||
build_weiche_merkmale, load_json, format_csv_line
|
||||
)
|
||||
|
||||
|
||||
@@ -100,6 +100,16 @@ class TestOmnifloExportUnit:
|
||||
))
|
||||
self.items = process_blocks(self.blocks, self.lookup)
|
||||
|
||||
# CSV in output speichern
|
||||
out_dir = _output_dir()
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
csv_path = os.path.join(out_dir, "omniflo_export.csv")
|
||||
header = "Elementnummer;TeileArt;TeileId;Bezeichnung;Anzahl;Merkmale"
|
||||
with open(csv_path, "w", encoding="utf-8") as f:
|
||||
f.write(header + "\n")
|
||||
for item in self.items:
|
||||
f.write(format_csv_line(item) + "\n")
|
||||
|
||||
def test_item_count_matches_testcases(self):
|
||||
"""Anzahl exportierter Elemente muss Anzahl Testfaelle entsprechen."""
|
||||
assert len(self.items) == len(self.tests), (
|
||||
@@ -348,3 +358,71 @@ class TestOmnifloExportCSV:
|
||||
assert not missing, (
|
||||
f"Zeile {i + 2}: Fehlende Weichen-Felder: {missing}"
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Referenz-Tests: CSV gegen Referenzdatei vergleichen
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _reference_dir():
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "reference")
|
||||
|
||||
|
||||
def _normalize_row(line):
|
||||
"""Splittet eine CSV-Zeile und ersetzt die TeileId (UUID) durch Platzhalter."""
|
||||
cols = line.strip().split(";", 5)
|
||||
if len(cols) >= 3:
|
||||
cols[2] = "<ID>"
|
||||
return cols
|
||||
|
||||
|
||||
class TestOmnifloReferenceCSV:
|
||||
"""Vergleicht den erzeugten Unit-Test-CSV-Export mit einer Referenzdatei."""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup(self):
|
||||
self.out_csv = os.path.join(_output_dir(), "omniflo_export.csv")
|
||||
self.ref_csv = os.path.join(_reference_dir(), "omniflo_export_reference.csv")
|
||||
if not os.path.exists(self.out_csv):
|
||||
pytest.skip(
|
||||
"omniflo_export.csv nicht vorhanden - "
|
||||
"zuerst TestOmnifloExportUnit ausfuehren"
|
||||
)
|
||||
if not os.path.exists(self.ref_csv):
|
||||
pytest.skip("Referenzdatei nicht vorhanden: " + self.ref_csv)
|
||||
with open(self.out_csv, "r", encoding="utf-8") as f:
|
||||
self.out_lines = f.readlines()
|
||||
with open(self.ref_csv, "r", encoding="utf-8") as f:
|
||||
self.ref_lines = f.readlines()
|
||||
|
||||
def test_header_matches_reference(self):
|
||||
"""Header muss mit Referenz uebereinstimmen."""
|
||||
assert self.out_lines[0].strip() == self.ref_lines[0].strip(), (
|
||||
f"Header abweichend:\n Ist: {self.out_lines[0].strip()}\n"
|
||||
f" Soll: {self.ref_lines[0].strip()}"
|
||||
)
|
||||
|
||||
def test_zeilenanzahl_matches_reference(self):
|
||||
"""Zeilenanzahl muss mit Referenz uebereinstimmen."""
|
||||
assert len(self.out_lines) == len(self.ref_lines), (
|
||||
f"Zeilenanzahl abweichend: Ist={len(self.out_lines)}, "
|
||||
f"Soll={len(self.ref_lines)}"
|
||||
)
|
||||
|
||||
def test_zeilen_matches_reference(self):
|
||||
"""Alle Zeilen muessen mit Referenz uebereinstimmen (TeileId wird ignoriert)."""
|
||||
min_lines = min(len(self.out_lines), len(self.ref_lines))
|
||||
diffs = []
|
||||
for i in range(1, min_lines):
|
||||
out_cols = _normalize_row(self.out_lines[i])
|
||||
ref_cols = _normalize_row(self.ref_lines[i])
|
||||
if out_cols != ref_cols:
|
||||
diffs.append(
|
||||
f"Zeile {i + 1}:\n"
|
||||
f" Ist: {self.out_lines[i].strip()[:120]}\n"
|
||||
f" Soll: {self.ref_lines[i].strip()[:120]}"
|
||||
)
|
||||
assert not diffs, (
|
||||
f"{len(diffs)} abweichende Zeile(n) (erste 5):\n" +
|
||||
"\n".join(diffs[:5])
|
||||
)
|
||||
|
||||
Vendored
+1146
-81
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user