Migrate apache mock_hide_server_version fixture to mock_http#23643
Migrate apache mock_hide_server_version fixture to mock_http#23643mwdd146980 wants to merge 2 commits intoDataDog:mwdd146980/httpx-migration-basefrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bf627bce1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| def filter_server_version(url, *args, **kwargs): | ||
| r = requests.get(url, **kwargs) | ||
| content = '\n'.join(line for line in r.text.splitlines() if 'ServerVersion' not in line) | ||
| return MockHTTPResponse(content=content, headers=dict(r.headers)) |
There was a problem hiding this comment.
Preserve upstream status code in mocked response
This fixture now wraps the real HTTP result in MockHTTPResponse without passing status_code, so it always defaults to 200. In test_metadata_in_header, that means Apache.check() no longer exercises its error path when the status endpoint returns 4xx/5xx, and the test can report success even though production would call raise_for_status() and fail. Propagating r.status_code (and ideally url) keeps the mock behavior aligned with the real response.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0bbc993 by passing status_code=r.status_code and url=r.url to MockHTTPResponse. Verified with ddev --no-interactive test apache -- -k test_metadata_in_header, which passed.
…version Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Motivation
Last
requests.Sessionpatch in apache test surface. Closes Step 5 conftest cleanup.Approach
Route version-stripping fixture through
mock_http. Side-effect performs real GET against HTTPD container brought up bydd_environment, then returnsMockHTTPResponsewithServerVersionfiltered out and headers preserved.Sole consumer is
test_metadata_in_header(@pytest.mark.usefixtures("dd_environment"), integration-style). Runs underddev test apache, notddev env test.Verification
ddev test -fs apachecleanddev --no-interactive test apache18 passed, 1 skippedddev --no-interactive test apache -- -k test_metadata_in_header1 passedPlan: https://datadoghq.atlassian.net/wiki/spaces/AI/pages/6677695868
🤖 Generated with Claude Code