(httpx_mock)
| 239 | |
| 240 | @pytest.mark.anyio |
| 241 | async def test_send_mints_idempotency_key(httpx_mock): |
| 242 | httpx_mock.add_response(json={"message_id": "msg_1", "status": "sent"}) |
| 243 | async with _client() as c: |
| 244 | await c.messages.send("bot@test.dev", {"to": ["a@x.com"], "subject": "Hi", "body": "yo"}) |
| 245 | req = httpx_mock.get_requests()[-1] |
| 246 | assert req.method == "POST" |
| 247 | assert "/v1/agents/bot%40test.dev/messages" in str(req.url) |
| 248 | assert req.headers.get("Idempotency-Key") |
| 249 | |
| 250 | |
| 251 | @pytest.mark.anyio |