Apply Black formatting to test files

This commit is contained in:
佐藤優一 2025-08-11 11:26:58 +09:00
parent dbeede9a31
commit f1fb1e3413
3 changed files with 16 additions and 10 deletions

View File

@ -35,6 +35,7 @@ def sample_config():
class MockResult:
"""Mock result that always has proper tool_calls attribute."""
def __init__(self, content="Test response", tool_calls=None):
self.content = content
self.tool_calls = tool_calls if tool_calls is not None else []
@ -52,17 +53,17 @@ def mock_llm():
# Simple approach: create a mock that will be returned by any chain operation
chain_result = Mock()
chain_result.return_value = default_result
# Mock the bind_tools to return a mock that handles piping
bound_mock = Mock()
bound_mock.invoke = Mock(return_value=default_result)
# Handle the pipe operation by returning a mock that also returns our result
def handle_pipe(other):
pipe_result = Mock()
pipe_result = Mock()
pipe_result.invoke = Mock(return_value=default_result)
return pipe_result
bound_mock.__ror__ = handle_pipe
mock.bind_tools.return_value = bound_mock

View File

@ -100,7 +100,9 @@ class TestMarketAnalyst:
"""Test that market analyst correctly processes state variables."""
# Setup
mock_toolkit.config = {"online_tools": False}
mock_result = MockResult(content="Analysis for AAPL on 2024-05-10", tool_calls=[])
mock_result = MockResult(
content="Analysis for AAPL on 2024-05-10", tool_calls=[]
)
# Mock the chain to capture the invoke call
mock_chain = Mock()
@ -125,7 +127,9 @@ class TestMarketAnalyst:
"""Test handling when no tool calls are made."""
# Setup
mock_toolkit.config = {"online_tools": False}
mock_result = MockResult(content="No tools needed", tool_calls=[]) # Empty tool calls
mock_result = MockResult(
content="No tools needed", tool_calls=[]
) # Empty tool calls
mock_llm.bind_tools.return_value.invoke.return_value = mock_result
analyst_node = create_market_analyst(mock_llm, mock_toolkit)
@ -146,7 +150,9 @@ class TestMarketAnalyst:
"""Test handling when tool calls are present."""
# Setup
mock_toolkit.config = {"online_tools": False}
mock_result = MockResult(content="Tool analysis", tool_calls=[Mock()]) # Non-empty tool calls
mock_result = MockResult(
content="Tool analysis", tool_calls=[Mock()]
) # Non-empty tool calls
mock_llm.bind_tools.return_value.invoke.return_value = mock_result
analyst_node = create_market_analyst(mock_llm, mock_toolkit)
@ -171,7 +177,7 @@ class TestMarketAnalyst:
mock_toolkit.config = {"online_tools": online_tools}
mock_result = MockResult(
content=f"Analysis in {'online' if online_tools else 'offline'} mode",
tool_calls=[]
tool_calls=[],
)
mock_llm.bind_tools.return_value.invoke.return_value = mock_result
@ -220,7 +226,7 @@ class TestMarketAnalystIntegration:
| MACD | +0.45 | Buy |
| Volume | High | Bullish |
""",
tool_calls=[]
tool_calls=[],
)
mock_llm.bind_tools.return_value.invoke.return_value = mock_result

View File

@ -1,7 +1,6 @@
"""Unit tests for dataflows utils module."""
class TestDataflowsUtils:
"""Test suite for dataflows utility functions."""