from __future__ import annotations import pytest from agent import image_gen_registry @pytest.fixture(autouse=True) def _reset_registry(): image_gen_registry._reset_for_tests() yield image_gen_registry._reset_for_tests() class TestPluginDispatch: def test_deepinfra_key_alone_does_not_select_image_backend(self, monkeypatch): """DeepInfra chat credentials do not imply consent to image billing.""" from tools import image_generation_tool monkeypatch.setenv("DEEPINFRA_API_KEY", "«redacted:sk-…»") monkeypatch.delenv("FAL_KEY", raising=False) monkeypatch.setattr(image_generation_tool, "_read_configured_image_provider", lambda: None) assert image_generation_tool._dispatch_to_plugin_provider("a cat", "square") is None def test_requirements_ignore_unselected_paid_plugin(self, monkeypatch): from tools import image_generation_tool monkeypatch.setattr(image_generation_tool, "check_fal_api_key", lambda: False) monkeypatch.setattr( image_generation_tool, "_read_configured_image_provider", lambda: None ) assert image_generation_tool.check_image_generation_requirements() is False