Fix mock status_code configuration#166
Open
mendral-app[bot] wants to merge 1 commit into
Open
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mock_clienttest fixture to return responses with integerstatus_code(200) by default, preventingValueErrorwhen auto-generated API code callsHTTPStatus(response.status_code)on an unconfigured MagicMockBL_ENV=testin the test environment to prevent Sentry initialization during test runs, eliminating false production alerts from test exceptionsFixes test noise in production Sentry (sdk-python project) where
ValueErrorexceptions fromHTTPStatus(MagicMock())were being reported as real incidents.Note
Created by Mendral. Tag @mendral-app with feedback or questions.