Skip to content

test: add 100% coverage tests for user_profile modules

Suma Pullaiahgari requested to merge tests/suma-updates into feature-final

What does this MR do and why?

This MR adds 100% test coverage for the user_profile module and improves overall test reliability.

📦 Coverage Improvements

Comprehensive unit tests have been added for the following modules:

File Statements Tests Added
user_profile/profile_service.py 140 56 tests
user_profile/profile_ui.py 96 22 tests
user_profile/profile_utils.py 58 6 tests (updated)
user_profile/render_user_profile.py 52 9 tests

Test Files Added (7 total)

  • tests/test_profile_service.py
  • tests/test_profile_ui.py
  • tests/test_profile_utils.py
  • tests/test_render_user_profile.py
  • tests/test_batch_utils.py
  • tests/test_asyncio_patch.py
  • tests/test_asyncio_patch_2.py

🔧 Additional Changes

  • Fixed mock decorator in test_batch_utils.py to support ttl argument
  • Updated pyproject.toml to exclude venv, .venv, build, and dist from Vulture checks
  • Updated mypy.ini to ignore missing imports for external dependencies

📊 Summary

  • Total test files: 7
  • Total tests added: 108+
  • Coverage achieved: 100% for user_profile module
  • Improves reliability and prevents regressions

References

  • Addresses test coverage gaps identified in code quality checks
  • Part of testing improvements for compliance checker module

Screenshots or screen recordings

Before After
Partial coverage 100% coverage

How to set up and validate locally

  1. Run all tests:
./venv/bin/python -m pytest tests/ -v
  1. Verify coverage:
./venv/bin/python -m pytest tests/ \
  --cov=user_profile.profile_service \
  --cov=user_profile.profile_ui \
  --cov=user_profile.profile_utils \
  --cov=user_profile.render_user_profile \
  --cov-report=term-missing
  1. Run full suite:
./venv/bin/python -m pytest tests/ -q

MR acceptance checklist

  • Tests added for all new code paths
  • All existing tests pass
  • Code coverage at 100% for modified files
  • No breaking changes to existing functionality
  • Follows project testing conventions
  • Documentation updated (if applicable)
  • No security issues introduced
  • No performance degradation
Edited by Suma Pullaiahgari

Merge request reports

Loading