test(test_03): replace keyword text, remove hardcoded fallback, update docstring

- Keyword text: 'rocket chat plugin preflight briefing dokumentieren'
  (all words only in keywords_context, no 100%-keyword match)
- Removed hardcoded _DEFAULT_ROCKETCHAT_PLUGIN_ROOM fallback
- Added _get_env_room_or_skip_plugin_room() — skips cleanly if
  RC_LIVE_ROCKETCHAT_PLUGIN_ROOM not set
- Updated assertion from 'hermes' to 'rocket'/'plugin'
- Updated docstring and fail messages

Ref: Rainer's review .hermes/reviews/rainer/test-anpassung-2026-07-29.md
This commit is contained in:
Bernd (Hermes)
2026-07-29 11:03:25 +02:00
parent cbe68efe58
commit 5d5e349239
+28 -12
View File
@@ -10,7 +10,8 @@ Räume:
Test-Szenario (echter Button-Move-Request-Pfad): Test-Szenario (echter Button-Move-Request-Pfad):
1. /reset an source_room senden (sticky-topic clear) 1. /reset an source_room senden (sticky-topic clear)
2. Context-Keyword-Text posten, der einen Room-Match via keywords_context 2. Context-Keyword-Text posten, der einen Room-Match via keywords_context
triggert (z.B. "hermes deployment pipeline" → #Rocketchat-Plugin) triggert (z.B. "rocket chat plugin preflight briefing dokumentieren"
→ #Rocketchat-Plugin). Kein 100%-Keyword enthalten.
3. Bot sendet Move-Request-Buttons in source_room (butler_mode=cognitive) 3. Bot sendet Move-Request-Buttons in source_room (butler_mode=cognitive)
4. Button-Payload "MOVE_REQ:<source_room_id>::confirm_move" via REST posten 4. Button-Payload "MOVE_REQ:<source_room_id>::confirm_move" via REST posten
5. Warten auf kopierte Nachricht im Zielraum (#Rocketchat-Plugin) 5. Warten auf kopierte Nachricht im Zielraum (#Rocketchat-Plugin)
@@ -52,8 +53,9 @@ from tests.live_rc.helpers.polling import (
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Room ID for #Rocketchat-Plugin from room-map.json (fallback if env var not set) # Room ID for #Rocketchat-Plugin from room-map.json.
_DEFAULT_ROCKETCHAT_PLUGIN_ROOM = "6a19b0ff02aeecd36b1aa16c" # No hardcoded fallback — must be set via RC_LIVE_ROCKETCHAT_PLUGIN_ROOM env var.
# If not set, the test skips cleanly (see _get_env_room_or_skip_plugin_room).
def _get_env_room(name: str) -> str: def _get_env_room(name: str) -> str:
@@ -64,6 +66,19 @@ def _get_env_room(name: str) -> str:
return val return val
def _get_env_room_or_skip_plugin_room() -> str:
"""Get the Rocketchat-Plugin room ID from env var, skip if not set."""
val = (os.getenv("RC_LIVE_ROCKETCHAT_PLUGIN_ROOM") or "").strip()
if not val:
pytest.skip(
"RC_LIVE_ROCKETCHAT_PLUGIN_ROOM not set — "
"cannot verify copied message in target room. "
"Set this env var to the room ID of #Rocketchat-Plugin "
"(or a test mirror room) to run this test."
)
return val
def _get_butler_mode(rc_client) -> str: def _get_butler_mode(rc_client) -> str:
"""Read butler_mode from env var or detect from bot. """Read butler_mode from env var or detect from bot.
@@ -133,9 +148,8 @@ def test_03_move_request(
target_room = _get_env_room("RC_LIVE_TARGET_ROOM") target_room = _get_env_room("RC_LIVE_TARGET_ROOM")
# Zielraum für die Kopie: #Rocketchat-Plugin (aus room-map.json) # Zielraum für die Kopie: #Rocketchat-Plugin (aus room-map.json)
rocket_chat_plugin_room = ( # Kein hardcoded Fallback — muss via RC_LIVE_ROCKETCHAT_PLUGIN_ROOM gesetzt sein.
os.getenv("RC_LIVE_ROCKETCHAT_PLUGIN_ROOM") or _DEFAULT_ROCKETCHAT_PLUGIN_ROOM rocket_chat_plugin_room = _get_env_room_or_skip_plugin_room()
).strip()
posted_ids_source: list = [] posted_ids_source: list = []
posted_ids_target: list = [] posted_ids_target: list = []
@@ -170,10 +184,12 @@ def test_03_move_request(
# ── Step 1: Post context-keyword message in source room ───────────── # ── Step 1: Post context-keyword message in source room ─────────────
# Use a context keyword (NOT 100% keyword) to trigger butler mode. # Use a context keyword (NOT 100% keyword) to trigger butler mode.
# "hermes" + "deployment" are keywords_context for #Rocketchat-Plugin. # All words in this text are only in keywords_context for #Rocketchat-Plugin,
# 100% keywords like "rocketchat" would auto-route (move_request_sent=False). # none are in keywords_100 — so the bot sends a Move-Request instead of
# auto-routing. (B-1 fix ensures multi-word keywords_100 like 'hermes-gateway'
# don't falsely match on single words.)
keyword_text = ( keyword_text = (
"hermes deployment pipeline — bitte in den Rocketchat-Plugin-Raum routen" "rocket chat plugin preflight briefing dokumentieren"
) )
msg_id, source_cursor = post_test_message( msg_id, source_cursor = post_test_message(
@@ -204,7 +220,7 @@ def test_03_move_request(
pytest.fail( pytest.fail(
f"Bot did not send move-request buttons in source room within 30s. " f"Bot did not send move-request buttons in source room within 30s. "
f"Check that butler_mode is not 'off' and the Archivar is running. " f"Check that butler_mode is not 'off' and the Archivar is running. "
f"Context keyword: 'hermes deployment pipeline'. Error: {e}" f"Context keyword: 'rocket chat plugin preflight briefing dokumentieren'. Error: {e}"
) )
move_req_text = move_req_msg.get("msg", "") move_req_text = move_req_msg.get("msg", "")
@@ -276,8 +292,8 @@ def test_03_move_request(
f"Copied message missing move prefix '(Auftrag von @...'. " f"Copied message missing move prefix '(Auftrag von @...'. "
f"Got: '{copied_text[:200]}'" f"Got: '{copied_text[:200]}'"
) )
assert "hermes" in copied_text.lower(), ( assert "rocket" in copied_text.lower() or "plugin" in copied_text.lower(), (
f"Copied message does not contain original keyword 'hermes'. " f"Copied message does not contain original keyword 'rocket'/'plugin'. "
f"Got: '{copied_text[:200]}'" f"Got: '{copied_text[:200]}'"
) )