|
1 | 1 | """Unit tests for IicpClient (ADR-016 SDK-01..SDK-06).""" |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
| 4 | +import httpx |
4 | 5 | import pytest |
5 | 6 | import respx |
6 | | -import httpx |
7 | 7 |
|
8 | 8 | from iicp_client import ( |
9 | | - IicpClient, |
10 | | - IicpError, |
11 | | - ClientConfig, |
12 | 9 | ChatMessage, |
13 | 10 | ChatOptions, |
14 | | - TaskRequest, |
15 | | - TaskConstraints, |
16 | | - TaskAuth, |
| 11 | + ClientConfig, |
17 | 12 | DiscoverOptions, |
| 13 | + IicpClient, |
| 14 | + IicpError, |
| 15 | + TaskAuth, |
| 16 | + TaskRequest, |
18 | 17 | ) |
19 | 18 |
|
20 | | - |
21 | 19 | DIRECTORY = "https://iicp.test" |
22 | 20 | NODE = "https://node.iicp.test" |
23 | 21 | DISCOVER_URL = f"{DIRECTORY}/v1/discover" |
@@ -134,7 +132,10 @@ async def _noop_sleep(_: float) -> None: |
134 | 132 | respx.post(TASK_URL).mock( |
135 | 133 | side_effect=[ |
136 | 134 | httpx.Response(503, json={"code": "IICP-E005", "message": "overload"}), |
137 | | - httpx.Response(200, json={"task_id": "t-2", "status": "success", "result": {}, "usage": {}}), |
| 135 | + httpx.Response( |
| 136 | + 200, |
| 137 | + json={"task_id": "t-2", "status": "success", "result": {}, "usage": {}}, |
| 138 | + ), |
138 | 139 | ] |
139 | 140 | ) |
140 | 141 | client = IicpClient(ClientConfig(directory_url=DIRECTORY, max_retries=3)) |
@@ -175,7 +176,10 @@ def test_chat_sdk02_openai_compat_shape(): |
175 | 176 | "status": "success", |
176 | 177 | "result": { |
177 | 178 | "choices": [ |
178 | | - {"message": {"role": "assistant", "content": "Hello!"}, "finish_reason": "stop"} |
| 179 | + { |
| 180 | + "message": {"role": "assistant", "content": "Hello!"}, |
| 181 | + "finish_reason": "stop", |
| 182 | + } |
179 | 183 | ], |
180 | 184 | "usage": {"prompt_tokens": 5, "completion_tokens": 3, "total_tokens": 8}, |
181 | 185 | "model": "llama3", |
|
0 commit comments