Skip to content

test: add comprehensive unit tests for medicine_service (98% coverage)

Vandana reddy Balannagari requested to merge test/medicine-service into develop

Merge Request

Overview

This MR improves the test coverage of medicine_service.py by adding comprehensive unit tests to cover all logic paths, branches, and exception handling, ensuring better reliability and stability of the module.

What does this MR do and why?

This MR focuses on improving the test coverage of the medicine service module, which previously had low coverage and untested execution paths.

The motivation is to reduce bugs and improve confidence in the code.

Approach:

  • Added unit tests for all functions
  • Covered all conditional branches
  • Covered exception handling
  • Included edge cases
  • Mocked dependencies

No changes were made to functionality or output.

Changes Made

  • Added comprehensive unit tests
  • Covered all execution paths
  • Covered if/else branches
  • Covered exception handling
  • Added edge case tests
  • Mocked external dependencies
  • Improved readability

Type of Change

  • 🧪 Test update

Related Issues / References

Closes #81 (closed)

How to Validate Locally

git checkout test/medicine-service
pytest
pytest --cov=app/services --cov-report=term-missing

Testing Done

  • Unit tests added
  • Tests passing

Test Cases Covered

Scenario Expected Result Status
Valid input Success
Invalid input Error
Edge cases Handled
Exceptions Handled
Branches Covered

Screenshots

before image

after Screenshot_from_2026-03-25_21-43-48

Notes

  • No functionality changes
  • Only test improvements
Edited by Vandana reddy Balannagari

Merge request reports

Loading