test: fix failing tests for detection and voice routers#594
test: fix failing tests for detection and voice routers#594RohanExploit merged 1 commit intomainfrom
Conversation
…on and voice routers - Fixes 404 errors by adding missing `/api/` prefix to test client URLs. - Fixes `test_transcribe_audio` by using the `MagicMock` to patch `backend.voice_service.VoiceService.transcribe_audio` with correctly shaped response dictionary. - Checks `data["original_text"]` instead of `data["text"]`.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
✅ Deploy Preview for fixmybharat canceled.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🙏 Thank you for your contribution, @RohanExploit!PR Details:
Quality Checklist:
Review Process:
Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken. |
There was a problem hiding this comment.
Pull request overview
Repairs backend unit tests by aligning test request paths and mocks with the FastAPI router registration under the /api prefix and the current voice transcription implementation.
Changes:
- Updated detection-related tests to call
/api/*endpoints (matchingapp.include_router(..., prefix="/api")). - Updated the voice transcription test to hit
/api/voice/transcribe, use the correct multipart field name, and patchbackend.voice_service.VoiceService.transcribe_audioto return the expected structured result. - Adjusted assertions to validate the voice endpoint response schema (
original_text).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/tests/test_severity.py | Fixes test URL to /api/detect-severity to match router mounting. |
| backend/tests/test_new_features.py | Fixes detection URLs and updates the voice transcription test to use the voice router endpoint + correct patch target/response assertion. |
| backend/tests/test_detection_bytes.py | Fixes detection URLs to /api/detect-vandalism and /api/detect-infrastructure to match router mounting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This branch repairs the backend unit test suite.
A few tests were making requests to un-prefixed URLs like
/detect-vandalism, but the actual router registers them under/api/. These test endpoints have been corrected.Additionally, the
transcribe_audiotest endpoint was expecting the wrong mock patching structure. We've switched to properly patchbackend.voice_service.VoiceService.transcribe_audio, returning a dictionary that mimics the expected schema, allowing the test to assert correctly against theoriginal_textproperty in the payload.No regressions have been detected across the Node and Python test suites.
PR created automatically by Jules for task 15488386273669320953 started by @RohanExploit