78c9a477e0
Root Cause: room_map.py:314 verwendete strict '>' statt Tiebreak-Comparator. Bei Score-Tie (z.B. 1:1) entschied Dict-Insertion-Order, nicht Logik. Fix (Option B, Rainer 2026-08-06): - Neue Tiebreak-Helper: _get_matched_keywords(), _keyword_room_count(), _tiebreak_compare() - Bei Score-Tie: Raum mit seltenerem Keyword (geringster room_count) gewinnt - Bei erneutem Tie: laengstes gematchtes Keyword gewinnt - Bei erneutem Tie: first-seen (stabil) - Tiebreak gilt fuer Stufe 1 (100%-Keywords) UND Stufe 3 (Kontext-Keywords) Tests: 6 neue Regressionstests in TestP033Tiebreak - 'Rocketchat' + 'Dokumentation' -> #Rocketchat-Plugin (nicht #LAN-Doku) - Nur 'Dokumentation' -> #LAN-Dokumentation (100%-Keyword schlaegt Kontext) - Nur 'Rocketchat' -> #Rocketchat-Plugin - Raritaet schlaegt Laenge - Stable-Sort bei identischen Keywords - Laenge gewinnt bei gleicher Raritaet Infra: plugin/conftest.py registriert 'plugin' in sys.modules fuer standalone-Tests (P-022 Flat-Modul-Pattern)
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""
|
|
Root conftest for rocketchat plugin tests.
|
|
|
|
Ensures the parent directory is on sys.path so that test files can use
|
|
``from plugin.archivar.room_map import ...``.
|
|
|
|
In the Hermes plugin runtime, the module is loaded as a flat module named
|
|
``rocketchat`` (P-022). In the git repo, the directory is named ``plugin``
|
|
and the module is importable as ``plugin`` directly. This conftest handles
|
|
both cases.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ensure the parent directory (containing the plugin package) is on sys.path
|
|
_parent_dir = str(Path(__file__).resolve().parent)
|
|
if _parent_dir not in sys.path:
|
|
sys.path.insert(0, _parent_dir)
|
|
|
|
# In the Hermes runtime, the plugin is loaded as a flat module named
|
|
# 'rocketchat', but test code imports from 'plugin.archivar.*'.
|
|
# Register 'plugin' as an alias for 'rocketchat' when running inside
|
|
# the Hermes plugin directory (not the git repo).
|
|
import importlib
|
|
|
|
try:
|
|
_rocketchat = importlib.import_module("rocketchat")
|
|
sys.modules["plugin"] = _rocketchat
|
|
# Register submodules
|
|
import rocketchat.archivar # noqa: E402
|
|
sys.modules["plugin.archivar"] = rocketchat.archivar
|
|
import rocketchat.archivar.room_map # noqa: E402
|
|
sys.modules["plugin.archivar.room_map"] = rocketchat.archivar.room_map
|
|
import rocketchat.archivar.keyword_matcher # noqa: E402
|
|
sys.modules["plugin.archivar.keyword_matcher"] = rocketchat.archivar.keyword_matcher
|
|
except ImportError:
|
|
# Running from git repo — 'plugin' is the real package name
|
|
pass
|