feat: added unit tests for decomposer.py#1402
Conversation
|
@madsysharma is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @madsysharma, thanks for contributing to Nyay Setu! 🎉 I have automatically:
Our workflows will now analyze your changes to classify:
Tip Ensure your PR description references the issue it resolves (e.g. Happy coding! 🚀 |
|
Hi @viru0909-dev , please review this PR. Thank you. |
viru0909-dev
left a comment
There was a problem hiding this comment.
Review Summary
This PR has been reviewed and requires changes before it can be approved. The issues below must be resolved.
Issues to Resolve
| Result | Check | Notes |
|---|---|---|
| FAIL | Title | Title should follow the conventional commit format (e.g., 'feat:', 'fix:', 'refactor:') or start with a capital letter. |
| FAIL | Issue Link | An issue number is referenced but without a closing keyword. Use 'Closes #NNN', 'Fixes #NNN', or 'Resolves #NNN' so the issue closes automatically on merge. |
Passing Checks
| Result | Check | Notes |
|---|---|---|
| PASS | Description | Description is complete and well-structured. |
| PASS | Checklist | All 8 checklist item(s) are checked. |
| PASS | Merge Conflicts | Conflict status is not yet computed by GitHub — skipping. |
| PASS | Branch Freshness | Branch was last updated 0.1 days ago. |
| PASS | CI / Tests | No CI checks are configured or results are not yet available. |
| PASS | Code Quality | No code quality issues detected in the diff. |
To proceed: push the required fixes to test/decomposer and the PR will be re-evaluated on the next review run.
|
Hi @viru0909-dev , have made the changes. Please review them and let me know if they're good to go. Thank you. |
feat: Add unit tests for
decomposer.pyCloses #852
Description
The layer-1 query decomposer (
nlp-orchestrator/decomposer.py) had only a thin smoke test. This PR replaces it with a comprehensivepytestsuite that fully isolates the logic from the Groq LPU by mocking the async chat-completion call: no API key and no network are required to run it.Cases covered:
[]) yields an empty list.[query]: invalid JSON,```jsonmarkdown fences (the decomposer does not strip them), a JSON object, a JSON scalar string, a list of non-strings, and a mixed-type list.Exception,TimeoutError, andRuntimeErrorfrom the client all fall back to[query]; the result is always a list.GROQ_MODEL_FAST,temperature=0.3,max_tokens=512, the"user"role, and that the user's query is interpolated intoDECOMPOSE_PROMPT.A clean
_mock_completion(content)helper replaces the previous nestedtype("obj", ...)mock construction. The module sets a dummyGROQ_API_KEYbefore import so the suite is runnable standalone (theconfigmodule callssys.exit(1)when the key is absent).Testing
Type of change
Checklist: