From b0f4a0555d2cfda66a497ed9b22be1568844cac0 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Sat, 25 Jul 2026 11:35:09 +0200 Subject: [PATCH] =?UTF-8?q?P1-Nacharbeit:=20Tests=20f=C3=BCr=20Issue=202?= =?UTF-8?q?=20=E2=80=94=20=5Fstrip=5Farchivar=5Fartifact()=20(Archivar-Out?= =?UTF-8?q?put-Marker)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../tests/test_reply_quote_stripper.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/plugin/archivar/tests/test_reply_quote_stripper.py b/plugin/archivar/tests/test_reply_quote_stripper.py index aa223f7..2adf30c 100644 --- a/plugin/archivar/tests/test_reply_quote_stripper.py +++ b/plugin/archivar/tests/test_reply_quote_stripper.py @@ -25,6 +25,7 @@ from plugin.archivar.reply_quote_stripper import ( _strip_rc_reply_link, _strip_blockquotes, _strip_quote_blocks, + _strip_archivar_artifact, ) @@ -383,3 +384,53 @@ class TestKeywordMatcherIntegration: assert match_keyword("dokumentiere", routing_text) # 'archivar' war im Quote → kein Match 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