import os os.environ["MOCK_INFERENCE"] = "true" from fastapi.testclient import TestClient from app import app client = TestClient(app) def test_chat_completions(): payload = { "model": "plain-qwen-0.5b", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "temperature": 0.0, "max_tokens": 100, "stream": False, "run_id": "test-run-123", "question_id": "test-q-456", "return_final_prompt": True } response = client.post("/v1/chat/completions", json=payload) assert response.status_code == 200 json_data = response.json() assert json_data["object"] == "chat.completion" assert "choices" in json_data assert json_data["choices"][0]["message"]["role"] == "assistant" assert "benchmark_metrics" in json_data metrics = json_data["benchmark_metrics"] assert metrics["model_id"] == "plain-qwen-0.5b" assert metrics["run_id"] == "test-run-123" assert metrics["question_id"] == "test-q-456" assert "prompt_tokens" in metrics assert "completion_tokens" in metrics