""" Shared pytest fixtures for the GuichetOI_ML test suite. After the restructure, the library is a normal Python package (`pip install -e .` or `pythonpath = src` in pytest.ini). The fixtures simply re-export the modules — kept for backwards compatibility with the existing test files. """ from __future__ import annotations import warnings import pytest from guichetoi import cms as _cms from guichetoi import inference as _inference from guichetoi import recommendation as _recommendation warnings.filterwarnings("ignore") @pytest.fixture(scope="session") def reco_mod(): """Recommendation engine module.""" return _recommendation @pytest.fixture(scope="session") def cms_mod(): """CMS generator module — depends only on openpyxl, fast import.""" return _cms @pytest.fixture(scope="session") def inference_mod(): """ Inference module — imports torch + transformers at module level, so this fixture is slow (~5-10 s on first call). Subsequent tests share the same cached module. """ return _inference @pytest.fixture def engine_no_pipeline(reco_mod): """ A RecommendationEngine instance constructed via __new__ to bypass the expensive `__init__` (which loads LayoutLMv3 models). Suitable for testing the rule-only methods (_build_verdict, _autorisation_matches, _filename_class_hint, _is_out_of_scope_file, _is_recolement_dossier). """ engine = reco_mod.RecommendationEngine.__new__(reco_mod.RecommendationEngine) engine.rules = reco_mod.RuleConfig() engine.pipeline = None return engine