Skip to content

Fix test suite routing and async modifiers#599

Open
RohanExploit wants to merge 1 commit intomainfrom
fix-pytest-async-routing-482903977578798018
Open

Fix test suite routing and async modifiers#599
RohanExploit wants to merge 1 commit intomainfrom
fix-pytest-async-routing-482903977578798018

Conversation

@RohanExploit
Copy link
Copy Markdown
Owner

@RohanExploit RohanExploit commented Mar 27, 2026

  • Refactored backend/tests/test_new_detectors.py to remove async def and pytest.mark.asyncio from synchronous TestClient requests.
  • Refactored backend/tests/test_detection_bytes.py similarly and added missing /api/ prefixes.
  • Refactored backend/tests/test_severity.py similarly and added missing /api/ prefix.
  • Updated backend/tests/test_new_features.py to include the missing /api/ prefix for /detect-waste, /detect-civic-eye, and /transcribe-audio.

PR created automatically by Jules for task 482903977578798018 started by @RohanExploit


Summary by cubic

Fixes the test suite by removing unnecessary async markers and updating routes to the correct /api/* paths. This prevents 404s and event loop issues, restoring passing tests for detection and severity endpoints.

  • Bug Fixes
    • Removed async def and @pytest.mark.asyncio from TestClient-based tests in backend/tests/test_new_detectors.py, backend/tests/test_detection_bytes.py, and backend/tests/test_severity.py.
    • Added missing /api/ prefix for /detect-vandalism, /detect-infrastructure, /detect-waste, /detect-civic-eye, /transcribe-audio, and /detect-severity in tests to match router mounts in main.py.

Written for commit 2744219. Summary will update on new commits.

Summary by CodeRabbit

  • Tests

    • Updated detection and analysis endpoint tests to use consolidated /api/ path structure
    • Modernized test execution patterns for improved compatibility
  • Chores

    • Enhanced test infrastructure alignment with current API organization

Removed `async def` and `@pytest.mark.asyncio` from synchronous `TestClient` tests in `test_new_detectors.py`, `test_detection_bytes.py`, and `test_severity.py`. Added missing `/api/` prefix to test endpoints for vandalism, infrastructure, waste, civic-eye, transcribe-audio, and severity to match modular router configuration in `main.py` and fix 404s.
Copilot AI review requested due to automatic review settings March 27, 2026 11:01
@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 27, 2026

Deploy Preview for fixmybharat canceled.

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

@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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

Four backend test files are updated to convert async test functions to synchronous versions and standardize API endpoint paths to use the /api/ prefix, aligning test requests with a new routing convention.

Changes

Cohort / File(s) Summary
Async-to-sync test conversion & path prefix updates
backend/tests/test_detection_bytes.py, backend/tests/test_new_detectors.py, backend/tests/test_severity.py
Removed @pytest.mark.asyncio decorators and converted async def test functions to synchronous def equivalents. Updated API endpoint paths to use /api/ prefix (e.g., "/detect-vandalism""/api/detect-vandalism").
API path prefix updates
backend/tests/test_new_features.py
Updated three API endpoint paths to use /api/ prefix: "/detect-waste""/api/detect-waste", "/detect-civic-eye""/api/detect-civic-eye", "/transcribe-audio""/api/transcribe-audio".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/m

Poem

🐰 The paths now lead to /api/ we hop,
Async becomes sync, the code's tip-top,
Four test files dance in unison bright,
Standards align—everything's right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix test suite routing and async modifiers' directly and accurately reflects the main changes: removing async markers and updating endpoint routing in test files.
Description check ✅ Passed The pull request description clearly lists all changes made across four test files, specifying the refactoring of async markers and addition of /api/ prefixes to align with endpoint configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pytest-async-routing-482903977578798018

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.

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 4 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

Adjusts backend tests to match the FastAPI app’s /api router mounting and to use synchronous TestClient patterns (removing unnecessary async test markers).

Changes:

  • Removed async def + pytest.mark.asyncio from tests that only use synchronous TestClient requests.
  • Updated affected test requests to include the missing /api/ prefix for detection/transcription endpoints.
  • Kept existing mocking patterns while aligning route paths with backend/main.py router prefixes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
backend/tests/test_new_detectors.py Converts tests to sync style (no pytest.mark.asyncio) while keeping TestClient usage.
backend/tests/test_detection_bytes.py Converts tests to sync style and fixes detection endpoint paths to /api/*.
backend/tests/test_severity.py Converts to sync test function and fixes severity endpoint path to /api/detect-severity.
backend/tests/test_new_features.py Fixes feature endpoint paths to /api/* (waste, civic-eye, transcribe-audio).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants