fix: V8.4.2.1 — UX-Bug INFO, Test-Assertions, Test-Isolation
Fix 1 (BEFUND 5): INFO-Konflikte senden keine Buttons mehr.
_ask_keyword_conflict_resolution() prüft jetzt ob alle Konflikte
INFO sind → reiner Text-Hinweis ohne Buttons. CRITICAL/WARNING
bekommen weiterhin Buttons.
Fix 2 (BEFUND 6): 3 Test-Assert-Erweiterungen.
test_conflict_buttons_sent_for_context_vs_100 prüft jetzt:
- ℹ️-Emoji im Text
- "Keine Aktion nötig" im Text
- Keine attachments (nur 2 args: room_id, text)
Fix 3 (BEFUND 7): Test-Isolation via /tmp/archivar_test_state.json.
_build_mock_adapter() setzt ARCHIVAR_STATE_PATH auf temp file
und löscht es vor jedem Test — verhindert persistierte
State-Leaks zwischen Testläufen (gleiches Pattern wie V8.4.1).
This commit is contained in:
@@ -3384,6 +3384,17 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
f"in {c['room_name']} ({severity}: {explanation})"
|
f"in {c['room_name']} ({severity}: {explanation})"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# V8.4.2.1: INFO-Konflikte sind reine Hinweise — keine Buttons
|
||||||
|
all_info = all(c["conflict_type"] == "INFO" for c in conflicts)
|
||||||
|
|
||||||
|
if all_info:
|
||||||
|
text = (
|
||||||
|
f"ℹ️ **Keyword-Hinweis** ({keyword_label}-Keywords):\n\n"
|
||||||
|
+ "\n".join(conflict_lines)
|
||||||
|
+ "\n\n💡 Der Butler wird im anderen Raum nachfragen. Keine Aktion nötig."
|
||||||
|
)
|
||||||
|
await self._post_message_with_retry(operator_room_id, text)
|
||||||
|
else:
|
||||||
text = (
|
text = (
|
||||||
f"⚠️ **Keyword-Konflikt erkannt** ({keyword_label}-Keywords):\n\n"
|
f"⚠️ **Keyword-Konflikt erkannt** ({keyword_label}-Keywords):\n\n"
|
||||||
+ "\n".join(conflict_lines)
|
+ "\n".join(conflict_lines)
|
||||||
|
|||||||
@@ -192,13 +192,22 @@ def _build_mock_adapter(room_map_path: str):
|
|||||||
"""Build a RocketChatAdapter with mocked external dependencies.
|
"""Build a RocketChatAdapter with mocked external dependencies.
|
||||||
|
|
||||||
Uses __new__ to skip __init__ (same pattern as test_v8_3_4.py).
|
Uses __new__ to skip __init__ (same pattern as test_v8_3_4.py).
|
||||||
|
V8.4.2.1: Isoliert ArchivarState via /tmp/archivar_test_state.json
|
||||||
|
um persistierte State-Leaks zwischen Testläufen zu verhindern.
|
||||||
"""
|
"""
|
||||||
os.environ["MULTIROOM_AGENT"] = "true"
|
os.environ["MULTIROOM_AGENT"] = "true"
|
||||||
os.environ["ARCHIVAR_ROOM_MAP_PATH"] = room_map_path
|
os.environ["ARCHIVAR_ROOM_MAP_PATH"] = room_map_path
|
||||||
|
os.environ["ARCHIVAR_STATE_PATH"] = "/tmp/archivar_test_state.json"
|
||||||
os.environ["ROCKETCHAT_BASE_URL"] = "https://rocket.example.com"
|
os.environ["ROCKETCHAT_BASE_URL"] = "https://rocket.example.com"
|
||||||
os.environ["ROCKETCHAT_USER"] = "testbot"
|
os.environ["ROCKETCHAT_USER"] = "testbot"
|
||||||
os.environ["ROCKETCHAT_PASSWORD"] = "testpass"
|
os.environ["ROCKETCHAT_PASSWORD"] = "testpass"
|
||||||
|
|
||||||
|
# Clean leftover state from previous runs
|
||||||
|
try:
|
||||||
|
os.remove("/tmp/archivar_test_state.json")
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
from plugin.adapter import RocketChatAdapter, RocketChatREST
|
from plugin.adapter import RocketChatAdapter, RocketChatREST
|
||||||
from archivar.conversation_history import ConversationHistory
|
from archivar.conversation_history import ConversationHistory
|
||||||
from archivar.multiroom_context import MultiRoomContextRing
|
from archivar.multiroom_context import MultiRoomContextRing
|
||||||
@@ -389,7 +398,7 @@ class TestV842OnboardingConflictResolution(unittest.TestCase):
|
|||||||
self.assertIn("WARNUNG", text)
|
self.assertIn("WARNUNG", text)
|
||||||
|
|
||||||
def test_conflict_buttons_sent_for_context_vs_100(self):
|
def test_conflict_buttons_sent_for_context_vs_100(self):
|
||||||
"""Kontext-Keyword vs 100%-Keyword → INFO-Buttons."""
|
"""Kontext-Keyword vs 100%-Keyword → INFO-Hinweis, KEINE Buttons."""
|
||||||
adapter = _build_mock_adapter(str(self.temp_path))
|
adapter = _build_mock_adapter(str(self.temp_path))
|
||||||
adapter._post_message_with_retry = AsyncMock(return_value=True)
|
adapter._post_message_with_retry = AsyncMock(return_value=True)
|
||||||
adapter._get_build_custom_buttons = MagicMock(return_value=MagicMock(return_value=[]))
|
adapter._get_build_custom_buttons = MagicMock(return_value=MagicMock(return_value=[]))
|
||||||
@@ -429,8 +438,14 @@ class TestV842OnboardingConflictResolution(unittest.TestCase):
|
|||||||
))
|
))
|
||||||
|
|
||||||
self.assertTrue(adapter._post_message_with_retry.called)
|
self.assertTrue(adapter._post_message_with_retry.called)
|
||||||
text = adapter._post_message_with_retry.call_args[0][1]
|
call_args = adapter._post_message_with_retry.call_args
|
||||||
|
text = call_args[0][1]
|
||||||
self.assertIn("INFO", text)
|
self.assertIn("INFO", text)
|
||||||
|
# V8.4.2.1: INFO sendet KEINE Buttons — nur Text-Hinweis
|
||||||
|
self.assertIn("ℹ️", text)
|
||||||
|
self.assertIn("Keine Aktion nötig", text)
|
||||||
|
# Keine attachments übergeben
|
||||||
|
self.assertEqual(len(call_args[0]), 2) # nur (room_id, text), kein attachments
|
||||||
|
|
||||||
def test_keep_anyway_proceeds_to_next_question(self):
|
def test_keep_anyway_proceeds_to_next_question(self):
|
||||||
"""'Trotzdem verwenden' → Keyword gespeichert, nächste Frage."""
|
"""'Trotzdem verwenden' → Keyword gespeichert, nächste Frage."""
|
||||||
|
|||||||
Reference in New Issue
Block a user