chore: adds harness test cases for file apis in anthropic - #4967
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdates the e2e provider harness JSON test collection: file response classification switches from ChangesAnthropic file harness
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/api/collections/provider-harness.json (1)
14899-15024: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd assertions that
content_typeoverride/inference actually took effect.Both new upload tests ("with content_type override" and "content_type inferred from file part") only assert
status is 200and thatj.idis a non-empty string. Per Anthropic's Files API, the upload response includes amime_typefield. Since the stated purpose of these two tests is to exercise explicit vs. inferredcontent_typebehavior, assertingj.mime_type(e.g.,text/markdownfor the override case) would make the test actually verify the feature under test rather than just verify the upload succeeded.♻️ Proposed assertion addition (override test)
"pm.test('status is 200', function () { pm.response.to.have.status(200); });", "var j = pm.response.json();", "pm.test('has file id', function () { pm.expect(j.id).to.be.a('string').and.not.empty; });", + "pm.test('content_type override applied', function () { pm.expect(j.mime_type).to.equal('text/markdown'); });", "pm.collectionVariables.set('anthropicUploadFileIdA', j.id);"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/api/collections/provider-harness.json` around lines 14899 - 15024, The two Anthropic upload tests only verify success and file ID, so they do not confirm the content_type behavior they are meant to cover. Update the test scripts in the "Anthropic: file upload with content_type override" and "Anthropic: file upload content_type inferred from file part" cases to assert the response's mime_type field, using the existing pm.response.json() result and the file upload response shape. Make the override case check the expected explicit type and the inferred case check the type derived from the uploaded file, so these tests actually validate the feature under test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/e2e/api/collections/provider-harness.json`:
- Around line 14899-15024: The two Anthropic upload tests only verify success
and file ID, so they do not confirm the content_type behavior they are meant to
cover. Update the test scripts in the "Anthropic: file upload with content_type
override" and "Anthropic: file upload content_type inferred from file part"
cases to assert the response's mime_type field, using the existing
pm.response.json() result and the file upload response shape. Make the override
case check the expected explicit type and the inferred case check the type
derived from the uploaded file, so these tests actually validate the feature
under test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 08ca6fd5-e486-4a31-95e1-4d972982e05d
📒 Files selected for processing (1)
tests/e2e/api/collections/provider-harness.json
d795008 to
8a0925a
Compare
e717c35 to
86e2330
Compare
The base branch was changed.
8a0925a to
ff036c1
Compare
ff036c1 to
356140e
Compare
Merge activity
|

Summary
Adds end-to-end test coverage for the Anthropic Files API, including file upload with an explicit
content_typeoverride, file upload withcontent_typeinferred from the file part, using an uploaded file as a document source in/v1/messages, and using an uploaded file viainput_filein/v1/responses. Cleanup requests delete both test files after the scenarios run.Changes
type: "file") and deleted file objects (type: "file_deleted") in the provider harness test script so the content-validation assertion correctly recognises Anthropic Files API responses.content_typefield (text/markdown) alongside the file, and one that relies on the content type being inferred from the uploaded file part.documentsource withfile_idin an Anthropic/v1/messagesrequest (the proxy is expected to inject thefiles-api-2025-04-14beta header automatically).input_file/file_idthrough the native/v1/responsesendpoint with an Anthropic model.anthropicUploadFileIdAandanthropicUploadFileIdB) to avoid leaving orphaned files after the test run.Type of change
Affected areas
How to test
Run the Postman/Newman collection against a running instance with a valid
anthropicKeyandbaseUrlset:Expected outcomes:
idfield.input_filepreview requests return a valid model response.Breaking changes
Related issues
Security considerations
The
anthropicKeyis supplied via an environment variable and is not hardcoded in the collection. No PII or secrets are stored in the test fixtures.Checklist
docs/contributing/README.mdand followed the guidelines