P1-Nacharbeit: Tests für Issue 2 — _strip_archivar_artifact() (Archivar-Output-Marker)
3 Tests in test_reply_quote_stripper.py::TestArchivarArtifactStripping: - test_archivar_phrase_detected_and_stripped: Archivar-Phrase erkannt, Raumnamen-Teil entfernt - test_normal_message_not_affected: Normale Nachricht ohne Archivar-Phrase bleibt unverändert - test_mixed_quote_and_content: Archivar-Phrase + normaler Content → Raumnamen entfernt, Telemetrie bleibt erhalten
This commit is contained in:
@@ -25,6 +25,7 @@ from plugin.archivar.reply_quote_stripper import (
|
|||||||
_strip_rc_reply_link,
|
_strip_rc_reply_link,
|
||||||
_strip_blockquotes,
|
_strip_blockquotes,
|
||||||
_strip_quote_blocks,
|
_strip_quote_blocks,
|
||||||
|
_strip_archivar_artifact,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -383,3 +384,53 @@ class TestKeywordMatcherIntegration:
|
|||||||
assert match_keyword("dokumentiere", routing_text)
|
assert match_keyword("dokumentiere", routing_text)
|
||||||
# 'archivar' war im Quote → kein Match
|
# 'archivar' war im Quote → kein Match
|
||||||
assert not match_keyword("archivar", routing_text)
|
assert not match_keyword("archivar", routing_text)
|
||||||
|
|
||||||
|
|
||||||
|
# ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
# FIX 5 (P1): ISSUE 2 — Archivar-Output-Marker (_strip_archivar_artifact)
|
||||||
|
# ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
|
||||||
|
class TestArchivarArtifactStripping:
|
||||||
|
"""Tests für _strip_archivar_artifact() — verhindert Fehl-Routing
|
||||||
|
durch Archivar-Output-Marker in Nachrichten."""
|
||||||
|
|
||||||
|
def test_archivar_phrase_detected_and_stripped(self):
|
||||||
|
"""Archivar-Phrase 'Soll ich diese Nachricht nach #RAUM kopieren?'
|
||||||
|
→ Raumnamen-Teil wird entfernt, 'LAN-Dokumentation' NICHT in routing_text."""
|
||||||
|
text = "Soll ich diese Nachricht nach #LAN-Dokumentation kopieren?"
|
||||||
|
result, artifact_detected = _strip_archivar_artifact(text)
|
||||||
|
assert artifact_detected is True
|
||||||
|
assert "LAN-Dokumentation" not in result, (
|
||||||
|
f"Raumname 'LAN-Dokumentation' sollte gestrippt sein, "
|
||||||
|
f"ist aber in: '{result}'"
|
||||||
|
)
|
||||||
|
# Der Rest nach dem Strip sollte nur noch "kopieren?" sein
|
||||||
|
assert "kopieren" in result.lower()
|
||||||
|
|
||||||
|
def test_normal_message_not_affected(self):
|
||||||
|
"""Normale Nachricht ohne Archivar-Phrase → 'LAN-Dokumentation' BLEIBT erhalten."""
|
||||||
|
text = "Ich habe eine Frage zur LAN-Dokumentation"
|
||||||
|
result, artifact_detected = _strip_archivar_artifact(text)
|
||||||
|
assert artifact_detected is False
|
||||||
|
assert result == text, (
|
||||||
|
f"Normale Nachricht sollte unverändert bleiben, ist aber: '{result}'"
|
||||||
|
)
|
||||||
|
assert "LAN-Dokumentation" in result
|
||||||
|
|
||||||
|
def test_mixed_quote_and_content(self):
|
||||||
|
"""Archivar-Phrase + normaler Content → Raumnamen-Teil entfernt,
|
||||||
|
aber 'Telemetrie' bleibt in routing_text."""
|
||||||
|
text = (
|
||||||
|
"Soll ich diese Nachricht nach #LAN-Dokumentation kopieren?\n"
|
||||||
|
"Analysiere bitte auch die Telemetrie"
|
||||||
|
)
|
||||||
|
result, artifact_detected = _strip_archivar_artifact(text)
|
||||||
|
assert artifact_detected is True
|
||||||
|
assert "LAN-Dokumentation" not in result, (
|
||||||
|
f"Raumname sollte gestrippt sein, ist aber in: '{result}'"
|
||||||
|
)
|
||||||
|
assert "Telemetrie" in result, (
|
||||||
|
f"'Telemetrie' sollte erhalten bleiben, ist aber nicht in: '{result}'"
|
||||||
|
)
|
||||||
|
assert "Analysiere" in result
|
||||||
|
|||||||
Reference in New Issue
Block a user