MCPcopy Create free account
hub / github.com/IBM/mcp-cli / create_for_testing

Method create_for_testing

src/mcp_cli/chat/testing.py:57–75  ·  view source on GitHub ↗

Factory for test contexts.

(
        cls,
        stream_manager: Any,
        provider: str | None = None,
        model: str | None = None,
    )

Source from the content-addressed store, hash-verified

55
56 @classmethod
57 def create_for_testing(
58 cls,
59 stream_manager: Any,
60 provider: str | None = None,
61 model: str | None = None,
62 ) -> "TestChatContext":
63 """Factory for test contexts."""
64 model_manager = ModelManager()
65
66 if provider and model:
67 model_manager.switch_model(provider, model)
68 elif provider:
69 model_manager.switch_provider(provider)
70 elif model:
71 # Switch model in current provider
72 current_provider = model_manager.get_active_provider()
73 model_manager.switch_model(current_provider, model)
74
75 return cls(stream_manager, model_manager)
76
77 async def _initialize_tools(self, on_progress=None) -> None:
78 """Test-specific tool initialization."""

Callers 5

test_provider_onlyMethod · 0.80
test_model_onlyMethod · 0.80

Calls 4

switch_modelMethod · 0.95
switch_providerMethod · 0.95
get_active_providerMethod · 0.95
ModelManagerClass · 0.90

Tested by

no test coverage detected