Full Coverage Initiative for medicine_service.py
Problem
The current test coverage for medicine_service.py is low (~26%), leaving several logic paths untested. This increases the risk of undetected bugs and reduces confidence in the service.
Additionally, the existing test file is not located in the correct directory structure, which affects maintainability and consistency.
Scope
- Improve unit test coverage for
medicine_service.py - Ensure all execution paths are covered
- Fix test file structure
Tasks
- Move test file to correct location:
-
tests/services/test_medicine_service.py→tests/test_services/test_medicine_service.py
-
- Add missing unit tests
- Cover all conditional branches (if/else)
- Add tests for exception handling
- Handle edge cases:
- null inputs
- empty inputs
- invalid data
- Improve mocking of dependencies
- Ensure clean and readable test structure
Expected Outcome
- Test coverage reaches 100% for
medicine_service.py - All branches and exception paths are tested
- Tests pass successfully using pytest
- No changes to existing service logic
Validation
Run the following commands:
pytest
pytest --cov=app/services --cov-report=term-missing
Edited by Vandana reddy Balannagari