Build an LLMExtractor whose provider is a MagicMock. Patching make_provider sidesteps eager client construction (e.g. OpenAIProvider's OpenAI() call which now fails when credentials are missing — irrelevant for these tests). retryable_exceptions is set so _call_llm's `except retrya
(
model: str = "openai/test-model",
run_dir: str | None = None,
debug: bool = False,
)
| 27 | |
| 28 | |
| 29 | def _make_mock_extractor( |
| 30 | model: str = "openai/test-model", |
| 31 | run_dir: str | None = None, |
| 32 | debug: bool = False, |
| 33 | ) -> LLMExtractor: |
| 34 | """Build an LLMExtractor whose provider is a MagicMock. |
| 35 | |
| 36 | Patching make_provider sidesteps eager client construction (e.g. |
| 37 | OpenAIProvider's OpenAI() call which now fails when credentials are |
| 38 | missing — irrelevant for these tests). retryable_exceptions is set |
| 39 | so _call_llm's `except retryable as e:` clause type-checks. |
| 40 | """ |
| 41 | cfg = ExtractorConfig(model=model, run_dir=run_dir, debug=debug) |
| 42 | provider = MagicMock(retryable_exceptions=(ConnectionError,)) |
| 43 | with ( |
| 44 | patch( |
| 45 | "explainshell.extraction.llm.extractor.make_provider", |
| 46 | return_value=provider, |
| 47 | ), |
| 48 | patch( |
| 49 | "explainshell.extraction.llm.extractor.make_batch_provider", |
| 50 | return_value=MagicMock(), |
| 51 | ), |
| 52 | ): |
| 53 | return LLMExtractor(cfg) |
| 54 | |
| 55 | |
| 56 | class TestExtractIntegration(unittest.TestCase): |
no test coverage detected