Skip to content

fix(tests): resolve duplicate_service vectorized test suite mismatch and test pollution#792

Open
harshitanagpal05 wants to merge 6 commits into
ritesh-1918:gssocfrom
harshitanagpal05:fix/duplicate-service-tests
Open

fix(tests): resolve duplicate_service vectorized test suite mismatch and test pollution#792
harshitanagpal05 wants to merge 6 commits into
ritesh-1918:gssocfrom
harshitanagpal05:fix/duplicate-service-tests

Conversation

@harshitanagpal05
Copy link
Copy Markdown
Contributor

@harshitanagpal05 harshitanagpal05 commented May 30, 2026

Summary

We have successfully resolved the test suite collection and runtime failures in the duplicate checking service tests.

Proposed Changes

  • Unloaded conftest.py Stub Module: Dynamically removes the backend.services.duplicate_service stub injected by conftest.py from sys.modules at test startup.
  • Implemented Global and Local PyTorch Mocking: Installed a global mock for the torch library to allow tests to call torch.stack() and torch.max() without failing on dummy MagicMock embeddings.
  • Prevented Test Pollution: Added a teardown_method inside TestCheckDuplicate to automatically reset the shared _mock_st.util.cos_sim mock side-effects and return values between test executions.
  • Corrected Multiple-Ticket Mocks to Vectorized Format: Refactored test_picks_best_match_among_multiple_tickets to model a single vectorized comparison call instead of looping individual comparisons.
    closes bug(tests): duplicate_service unit tests fail with TypeErrors & IndexErrors when running against actual vectorized service #790

Verification Results

All 24 unit tests now compile and pass cleanly in 14.48s:

backend\tests\test_duplicate_service.py ........................         [100%]
============================= 24 passed in 14.48s =============================

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@harshitanagpal05 is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 68566090-fa37-428e-941b-9638e6b217c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:testing Testing suites, mock coverages, CI/CD integrations labels May 31, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Superb implementation, @harshitanagpal05! I've successfully resolved all conflicts in your PR and queued it for merging into gssoc.

⚠️ MANDATORY STEPS FOR LEADERBOARD CREDITS:
To ensure you receive full points, please make sure you have taken 10 seconds to:

Keep up the outstanding work! Let's build together! 🔥

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

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:testing Testing suites, mock coverages, CI/CD integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants