care icon indicating copy to clipboard operation
care copied to clipboard

Test cases for Inventory items apis

Open nandkishorr opened this issue 3 months ago • 2 comments

Merge Checklist

  • [ ] Tests added/fixed
  • [ ] Update docs in /docs
  • [ ] Linting Complete
  • [ ] Any other necessary step

Only PR's with test cases included and passing lint and test pipelines will be reviewed

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for the Inventory Item API:
      • Access control for super users, permitted users, and unauthorized users.
      • Retrieval of individual inventory items.
      • Listing with filters (product knowledge, status) and include_children behavior with ordering.
    • Improves reliability and confidence in existing inventory API behavior; no user-facing feature changes.

✏️ Tip: You can customize this high-level summary in your review settings.

nandkishorr avatar Sep 04 '25 05:09 nandkishorr

📝 Walkthrough

Walkthrough

Adds a new Django REST Framework test suite validating InventoryItem API detail/list endpoints, permission checks, filters (product_knowledge, status), and include_children behavior; includes setup helpers to create users, roles, facility/location, product entities, and inventory items.

Changes

Cohort / File(s) Summary
New tests for Inventory Item API
care/emr/tests/test_inventory_item_api.py
Adds InventoryItemAPITest with setUp() and helper creators (create_facility_location, create_product_knowledge, create_charge_item_definition, create_product, create_inventory_item), URL builders, and tests for retrieval (superuser, permitted user, forbidden user) and listing with filters: product_knowledge, status, include_children (true/false) and permission gating.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check permission setup and role assignment in setUp().
  • Verify list-filter expectations and ordering for include_children.
  • Ensure object creation helpers produce realistic relations and external_id usage.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description only includes a merge checklist but is missing key sections: 'Proposed Changes' and 'Associated Issue' are absent. Add 'Proposed Changes' section explaining the test cases added and 'Associated Issue' section linking to the relevant issue/feature request.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding test cases for Inventory items APIs.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch nandkishorr/test/inventory

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.

coderabbitai[bot] avatar Sep 04 '25 05:09 coderabbitai[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 54.84%. Comparing base (9ab6e7f) to head (0a5662c). :warning: Report is 259 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3232   +/-   ##
========================================
  Coverage    54.84%   54.84%           
========================================
  Files          380      380           
  Lines        16489    16489           
  Branches      1727     1727           
========================================
  Hits          9044     9044           
  Misses        7419     7419           
  Partials        26       26           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Sep 04 '25 05:09 codecov[bot]