WIP: Regression hell
This commit is contained in:
@@ -111,3 +111,55 @@ def test_deepseek_streaming(mock_post: MagicMock) -> None:
|
||||
|
||||
result = ai_client.send(md_content="Context", user_message="Stream test", base_dir=".", stream=True)
|
||||
assert result == "Hello World"
|
||||
|
||||
@patch("requests.post")
|
||||
def test_deepseek_payload_verification(mock_post: MagicMock) -> None:
|
||||
"""
|
||||
Verifies that the correct JSON payload (tools, history, params) is sent to DeepSeek.
|
||||
"""
|
||||
ai_client.set_provider("deepseek", "deepseek-chat")
|
||||
ai_client.reset_session()
|
||||
with patch("src.ai_client._load_credentials", return_value={"deepseek": {"api_key": "test-key"}}):
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = {
|
||||
"choices": [{"message": {"content": "OK"}, "finish_reason": "stop"}]
|
||||
}
|
||||
mock_post.return_value = mock_response
|
||||
|
||||
ai_client.send(md_content="Context", user_message="Message 1", base_dir=".", discussion_history="History")
|
||||
|
||||
args, kwargs = mock_post.call_args
|
||||
payload = kwargs["json"]
|
||||
|
||||
assert payload["model"] == "deepseek-chat"
|
||||
assert "tools" in payload
|
||||
assert len(payload["messages"]) == 2 # system + user
|
||||
assert "[DISCUSSION HISTORY]\n\nHistory" in payload["messages"][1]["content"]
|
||||
assert "temperature" in payload
|
||||
assert "max_tokens" in payload
|
||||
|
||||
@patch("requests.post")
|
||||
def test_deepseek_reasoner_payload_verification(mock_post: MagicMock) -> None:
|
||||
"""
|
||||
Verifies that deepseek-reasoner payload excludes tools and temperature.
|
||||
"""
|
||||
ai_client.set_provider("deepseek", "deepseek-reasoner")
|
||||
ai_client.reset_session()
|
||||
with patch("src.ai_client._load_credentials", return_value={"deepseek": {"api_key": "test-key"}}):
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = {
|
||||
"choices": [{"message": {"content": "OK"}, "finish_reason": "stop"}]
|
||||
}
|
||||
mock_post.return_value = mock_response
|
||||
|
||||
ai_client.send(md_content="Context", user_message="Message 1", base_dir=".")
|
||||
|
||||
args, kwargs = mock_post.call_args
|
||||
payload = kwargs["json"]
|
||||
|
||||
assert payload["model"] == "deepseek-reasoner"
|
||||
assert "tools" not in payload
|
||||
assert "temperature" not in payload
|
||||
assert "max_tokens" not in payload
|
||||
|
||||
Reference in New Issue
Block a user