(sync: bool, respx_mock: MockRouter)
| 534 | @pytest.mark.asyncio() |
| 535 | @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) |
| 536 | async def test_sigv4_binary_file_upload(sync: bool, respx_mock: MockRouter) -> None: |
| 537 | respx_mock.post(re.compile(r"https://aws-external-anthropic\.us-east-1\.api\.aws/.*")).mock( |
| 538 | return_value=httpx2.Response(200, json={"id": "file_123", "type": "file"}) |
| 539 | ) |
| 540 | png = b"\x89PNG\r\n\x1a\n\x00\xff\xfe" |
| 541 | |
| 542 | if sync: |
| 543 | AnthropicAWS( |
| 544 | aws_access_key="AKID", aws_secret_key="secret", aws_region="us-east-1", workspace_id="ws-123" |
| 545 | ).files.upload(file=("x.png", png, "image/png")) |
| 546 | else: |
| 547 | await AsyncAnthropicAWS( |
| 548 | aws_access_key="AKID", aws_secret_key="secret", aws_region="us-east-1", workspace_id="ws-123" |
| 549 | ).files.upload(file=("x.png", png, "image/png")) |
| 550 | |
| 551 | calls = cast("list[MockRequestCall]", respx_mock.calls) |
| 552 | assert len(calls) == 1 |
| 553 | assert str(calls[0].request.url) == "https://aws-external-anthropic.us-east-1.api.aws/v1/files" |
| 554 | assert png in calls[0].request.content |
| 555 | assert calls[0].request.headers["Authorization"].startswith("AWS4-HMAC-SHA256 ") |
| 556 | |
| 557 | |
| 558 | def respond_to_user_profiles(request: httpx2.Request) -> httpx2.Response: |
nothing calls this directly
no test coverage detected