Skip to content

Fix mock status_code configuration#166

Open
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/fix-mock-status-code
Open

Fix mock status_code configuration#166
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/fix-mock-status-code

Conversation

@mendral-app

@mendral-app mendral-app Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Configure the mock_client test fixture to return responses with integer status_code (200) by default, preventing ValueError when auto-generated API code calls HTTPStatus(response.status_code) on an unconfigured MagicMock
  • Set BL_ENV=test in the test environment to prevent Sentry initialization during test runs, eliminating false production alerts from test exceptions

Fixes test noise in production Sentry (sdk-python project) where ValueError exceptions from HTTPStatus(MagicMock()) were being reported as real incidents.


Note

Created by Mendral. Tag @mendral-app with feedback or questions.

The mock_client fixture yielded a bare MagicMock, so any test code
reaching client.get_httpx_client().request().status_code would get
another MagicMock instead of an integer. The auto-generated API client
code calls HTTPStatus(response.status_code), which raises ValueError
on non-integer input. These errors were then reported to the production
Sentry project because BL_ENV defaulted to 'prod' during test runs.

Changes:
- Pre-configure get_httpx_client().request() and
  get_async_httpx_client().request() return values with status_code=200
  and sensible defaults for content, headers, and json()
- Set BL_ENV=test in the session-scoped test environment fixture to
  prevent Sentry initialization during tests (init_sentry skips
  environments other than dev/prod)
@mendral-app mendral-app Bot requested a review from a team June 10, 2026 19:58
@mendral-app mendral-app Bot marked this pull request as ready for review June 10, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants