Skip to content

Migrate conftest.py MockResponse fixture chains to MockHTTPResponse#23226

Open
mwdd146980 wants to merge 4 commits intomwdd146980/step3d-batch-migrate-mockresponsefrom
mwdd146980/step3e-conftest-migration
Open

Migrate conftest.py MockResponse fixture chains to MockHTTPResponse#23226
mwdd146980 wants to merge 4 commits intomwdd146980/step3d-batch-migrate-mockresponsefrom
mwdd146980/step3e-conftest-migration

Conversation

@mwdd146980
Copy link
Copy Markdown
Contributor

@mwdd146980 mwdd146980 commented Apr 8, 2026

Motivation

Part of the requests→httpx test decoupling. 13 conftest.py files still import MockResponse and 11 patch requests.Session.* — both break when the HTTP backend switches to httpx.

Approach

Swap MockResponseMockHTTPResponse in all 13 files. For 10 integrations, also replace requests.Session.* patches with the mock_http fixture (mock_http.get.side_effect = routing_fn). Two partial migrations:

  • openstack_controller: import swap only — keystoneauth1 SDK needs a real requests.Session in the chain (details)
  • yarn mocked_bad_cert_request: kept Session patch — tests verify=True vs False which requires RequestsWrapper in the chain (details)

Also widens citrix_hypervisor JSONDecodeError except clause (same pattern as steps 3c/3d) and bumps minimum datadog-checks-base to >=37.35.0 for all 13 integrations since their conftest.py now imports from http_testing (added in PR #22676).

Verification

All 13 integration test suites pass (ddev --no-interactive test --recreate).

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 91.48936% with 12 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (mwdd146980/step3d-batch-migrate-mockresponse@5b6df5a). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwdd146980 mwdd146980 force-pushed the mwdd146980/step3e-conftest-migration branch from ce699e0 to 573c1ba Compare April 8, 2026 22:43
@mwdd146980
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96bc51f8db

ℹ️ 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".

mwdd146980 and others added 3 commits April 10, 2026 13:45
Replace MockResponse with MockHTTPResponse in 13 conftest.py files.
For 10 integrations, also migrate requests.Session.* patches to use
the mock_http fixture with configured side_effect, making tests
backend-agnostic. openstack_controller keeps Session patches due to
keystoneauth1 SDK coupling. Widen citrix_hypervisor JSONDecodeError
except clause for stdlib compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mwdd146980 mwdd146980 force-pushed the mwdd146980/step3e-conftest-migration branch from 96bc51f to e79d221 Compare April 10, 2026 18:15
@mwdd146980 mwdd146980 force-pushed the mwdd146980/step3d-batch-migrate-mockresponse branch from 000eac1 to 5b6df5a Compare April 10, 2026 18:15
@datadog-official

This comment has been minimized.

These conftest.py files now import from datadog_checks.base.utils.http_testing
which was added in PR #22676. The minimum-base-package CI test installs the
oldest pinned base version from PyPI, which doesn't have this module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mwdd146980 mwdd146980 self-assigned this Apr 10, 2026
@mwdd146980 mwdd146980 marked this pull request as ready for review April 10, 2026 20:05
@mwdd146980 mwdd146980 requested a review from a team as a code owner April 10, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment