Skip to content

test: fix failing tests for detection and voice routers#594

Merged
RohanExploit merged 1 commit intomainfrom
fix-backend-tests-mock-urls-15488386273669320953
Mar 29, 2026
Merged

test: fix failing tests for detection and voice routers#594
RohanExploit merged 1 commit intomainfrom
fix-backend-tests-mock-urls-15488386273669320953

Conversation

@RohanExploit
Copy link
Copy Markdown
Owner

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_audio test endpoint was expecting the wrong mock patching structure. We've switched to properly patch backend.voice_service.VoiceService.transcribe_audio, returning a dictionary that mimics the expected schema, allowing the test to assert correctly against the original_text property 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

…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"]`.
Copilot AI review requested due to automatic review settings March 26, 2026 10:55
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for fixmybharat canceled.

Name Link
🔨 Latest commit acffd7c
🔍 Latest deploy log https://app.netlify.com/projects/fixmybharat/deploys/69c510b7eb4f35000821a833

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Warning

Rate limit exceeded

@RohanExploit has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c37dc329-575b-481d-96e2-e4cf1de28e9a

📥 Commits

Reviewing files that changed from the base of the PR and between 19ef62d and acffd7c.

📒 Files selected for processing (3)
  • backend/tests/test_detection_bytes.py
  • backend/tests/test_new_features.py
  • backend/tests/test_severity.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-backend-tests-mock-urls-15488386273669320953

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🙏 Thank you for your contribution, @RohanExploit!

PR Details:

Quality Checklist:
Please ensure your PR meets the following criteria:

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Code is commented where necessary
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated (if applicable)
  • All tests passing locally
  • No breaking changes to existing functionality

Review Process:

  1. Automated checks will run on your code
  2. A maintainer will review your changes
  3. Address any requested changes promptly
  4. Once approved, your PR will be merged! 🎉

Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken.

@RohanExploit RohanExploit temporarily deployed to fix-backend-tests-mock-urls-15488386273669320953 - vishwaguru-backend PR #594 March 26, 2026 10:55 — with Render Destroyed
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-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.

No issues found across 3 files

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

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 (matching app.include_router(..., prefix="/api")).
  • Updated the voice transcription test to hit /api/voice/transcribe, use the correct multipart field name, and patch backend.voice_service.VoiceService.transcribe_audio to 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.

@RohanExploit RohanExploit merged commit cf5ed76 into main Mar 29, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants