""" 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