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

Class MockContext

tests/chat/test_conversation.py:36–61  ·  view source on GitHub ↗

Mock context for testing.

Source from the content-addressed store, hash-verified

34
35
36class MockContext:
37 """Mock context for testing."""
38
39 def __init__(self):
40 self.conversation_history = []
41 self.openai_tools = []
42 self.tool_name_mapping = {}
43 self.client = MagicMock()
44 self.tool_manager = MagicMock()
45 # Make tool_manager async methods work properly
46 self.tool_manager.get_adapted_tools_for_llm = AsyncMock(return_value=([], {}))
47 self.provider = "openai"
48
49 async def add_assistant_message(self, content):
50 """Add assistant message to conversation history."""
51 self.conversation_history.append(
52 Message(role=MessageRole.ASSISTANT, content=content)
53 )
54
55 def inject_assistant_message(self, message):
56 """Inject a message into conversation history."""
57 self.conversation_history.append(message)
58
59 def inject_tool_message(self, message):
60 """Inject a tool message into conversation history."""
61 self.conversation_history.append(message)
62
63
64class TestConversationProcessorInit:

Calls

no outgoing calls