Skip to content

fix(tests): mock rl.agent_optimizer in feedback coverage tests#1343

Merged
anchapin merged 1 commit into
mainfrom
fix/1341-clean
May 7, 2026
Merged

fix(tests): mock rl.agent_optimizer in feedback coverage tests#1343
anchapin merged 1 commit into
mainfrom
fix/1341-clean

Conversation

@anchapin
Copy link
Copy Markdown
Owner

@anchapin anchapin commented May 7, 2026

Closes #1341

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
Copilot AI review requested due to automatic review settings May 7, 2026 07:35
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Sorry @anchapin, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@anchapin anchapin merged commit e4967a0 into main May 7, 2026
34 of 42 checks passed
@anchapin anchapin deleted the fix/1341-clean branch May 7, 2026 07:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/compare requests in patch.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.modules patching).

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.

test_api_feedback_coverage.py tests fail - returning 200 instead of 503

3 participants