fix(tests): mock rl.agent_optimizer in feedback coverage tests#1343
Merged
Conversation
The import_error tests were returning 200 instead of 503 because they didn't properly mock the rl.agent_optimizer module. In CI, the dynamic path resolution allowed the import to succeed. Fixes: #1341
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes flaky/pre-existing failures in the Feedback API coverage tests by reliably simulating an unavailable rl.agent_optimizer module, so the /ai/performance/* endpoints return 503 as intended (Closes #1341).
Changes:
- Wrap
/ai/performance/agents,/ai/performance/agents/{agent_type}, and/ai/performance/comparerequests inpatch.dict("sys.modules", {"rl.agent_optimizer": None})to force an import failure during the request. - Align the coverage tests’ mocking approach with the already-working targeted tests (which use
sys.modulespatching).
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.
Closes #1341