feat: add robust validation and 100% branch coverage for _derive_grade#63
Conversation
|
@BHOGALA-SRIKA is attempting to deploy a commit to the karan3431's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
🎉 Thank you for your Pull Request! We're thrilled to have your contribution to FreshScan AI. Before we review, please make sure you have:
A maintainer will review your code as soon as possible! |
jpdevhub
left a comment
There was a problem hiding this comment.
Excellent work on this PR! The strict type validation for the grading boundaries is a great addition, and the way you isolated the heavy ML modules using sys.modules interception in the tests is fantastic. I confirmed it drops the test suite execution time to less than a second.
Once that duplicate block at the bottom of the test file is removed, this is good to go!
| mock_inference = MagicMock() | ||
| # Provide dummy mock functions so main.py can unpack them during import | ||
| mock_inference.load_models = MagicMock() | ||
| mock_inference.predict_stream_a = MagicMock() | ||
| mock_inference.predict_stream_b = MagicMock() | ||
| sys.modules['inference'] = mock_inference | ||
|
|
There was a problem hiding this comment.
This code is dublicated since you already correctly placed this mock interception at the very top of the file (lines 14-27) where it belongs, the block at the bottom is redundant and should be deleted.
There was a problem hiding this comment.
Thanks for the review. I caught that duplicate block, cleaned it up, and just pushed the final refactored file structure. It should be 100% clean and ready now.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Closes #10
Description
This PR resolves the issue tracking critical business logic testing for the backend grading utility. It introduces comprehensive validation checking and branch coverage for
_derive_gradeinmain.pyto prevent regression bugs.Changes Made
isinstanceto catch and gracefully reject non-numeric inputs (str,NoneType,list,bool), raising a cleanValueErrorinstead of unhandled runtime crashes.0and100inclusive.sys.modulesinterception intests/test_ci.pyto isolate tests from heavy third-party framework layers (torchbinary paths andsupabasenetwork connections), dropping local CI suite test execution to < 2 seconds.Checklist
npm run lintpasses with no errorsnpm run buildcompiles without TypeScript errorspython -m pytestpasses (including new tests I added).envfiles, API keys, secrets, model weights, or__pycache__in this diffmain, not merged