Fix code formatting for CI

This commit is contained in:
Lina Tawfik 2025-06-12 00:20:28 -07:00
parent 6ca3514261
commit 63ef121e18
No known key found for this signature in database
8 changed files with 101 additions and 79 deletions

View file

@ -13,13 +13,14 @@ class TestQueryFunction:
def test_query_single_prompt(self):
"""Test query with a single prompt."""
async def _test():
with patch('claude_code_sdk._internal.client.InternalClient.process_query') as mock_process:
with patch(
"claude_code_sdk._internal.client.InternalClient.process_query"
) as mock_process:
# Mock the async generator
async def mock_generator():
yield AssistantMessage(
content=[TextBlock(text="4")]
)
yield AssistantMessage(content=[TextBlock(text="4")])
mock_process.return_value = mock_generator()
@ -35,12 +36,14 @@ class TestQueryFunction:
def test_query_with_options(self):
"""Test query with various options."""
async def _test():
with patch('claude_code_sdk._internal.client.InternalClient.process_query') as mock_process:
with patch(
"claude_code_sdk._internal.client.InternalClient.process_query"
) as mock_process:
async def mock_generator():
yield AssistantMessage(
content=[TextBlock(text="Hello!")]
)
yield AssistantMessage(content=[TextBlock(text="Hello!")])
mock_process.return_value = mock_generator()
@ -48,28 +51,28 @@ class TestQueryFunction:
allowed_tools=["Read", "Write"],
system_prompt="You are helpful",
permission_mode="acceptEdits",
max_turns=5
max_turns=5,
)
messages = []
async for msg in query(
prompt="Hi",
options=options
):
async for msg in query(prompt="Hi", options=options):
messages.append(msg)
# Verify process_query was called with correct prompt and options
mock_process.assert_called_once()
call_args = mock_process.call_args
assert call_args[1]['prompt'] == "Hi"
assert call_args[1]['options'] == options
assert call_args[1]["prompt"] == "Hi"
assert call_args[1]["options"] == options
anyio.run(_test)
def test_query_with_cwd(self):
"""Test query with custom working directory."""
async def _test():
with patch('claude_code_sdk._internal.client.SubprocessCLITransport') as mock_transport_class:
with patch(
"claude_code_sdk._internal.client.SubprocessCLITransport"
) as mock_transport_class:
mock_transport = AsyncMock()
mock_transport_class.return_value = mock_transport
@ -79,8 +82,8 @@ class TestQueryFunction:
"type": "assistant",
"message": {
"role": "assistant",
"content": [{"type": "text", "text": "Done"}]
}
"content": [{"type": "text", "text": "Done"}],
},
}
yield {
"type": "result",
@ -91,7 +94,7 @@ class TestQueryFunction:
"is_error": False,
"num_turns": 1,
"session_id": "test-session",
"total_cost": 0.001
"total_cost": 0.001,
}
mock_transport.receive_messages = mock_receive
@ -100,16 +103,13 @@ class TestQueryFunction:
options = ClaudeCodeOptions(cwd="/custom/path")
messages = []
async for msg in query(
prompt="test",
options=options
):
async for msg in query(prompt="test", options=options):
messages.append(msg)
# Verify transport was created with correct parameters
mock_transport_class.assert_called_once()
call_kwargs = mock_transport_class.call_args.kwargs
assert call_kwargs['prompt'] == "test"
assert call_kwargs['options'].cwd == "/custom/path"
assert call_kwargs["prompt"] == "test"
assert call_kwargs["options"].cwd == "/custom/path"
anyio.run(_test)