Skip to content

test: improve unit test coverage toward 80% target #46

@JohnRDOrazio

Description

@JohnRDOrazio

Problem

OntoKit API has 136 tests at 40% code coverage. Major areas are untested:

  • collab/ module: 0%
  • Core services (project, PR, ontology, git): 10-27%
  • Route handlers: 23-54%
  • Worker tasks: 17%

Plan

Add ~200 tests across 22 new files + set up integration test infrastructure in CI.

Phase 1: Foundations

  • Add PostgreSQL (pgvector/pgvector:pg17) and Redis service containers to CI workflow
  • Add shared test fixtures (mock_arq_pool, bare_git_repo, authed_client)

Phase 2: Pure Unit Tests (Tier 1 — highest ROI)

  • collab/presence.py: 0% → 95%
  • collab/transform.py: 0% → 95%
  • collab/protocol.py: 0% → 90%
  • core/encryption.py: 35% → 95%
  • services/notification_service.py: 34% → 80%
  • services/user_service.py: 17% → 75%
  • services/github_service.py: 36% → 75%

Phase 3: Service Tests (Tier 2)

  • services/project_service.py: 15% → 55%
  • services/ontology_index.py: 13% → 55%
  • services/ontology.py: 27% → 55%
  • services/remote_sync_service.py: 21% → 65%
  • services/join_request_service.py: 18% → 60%

Phase 4: Route Tests (Tier 3)

  • api/routes/auth.py: 24% → 70%
  • api/routes/lint.py: 24% → 60%
  • api/routes/notifications.py: 73% → 92%
  • api/routes/quality.py: 38% → 65%
  • api/routes/user_settings.py: 33% → 65%

Phase 5: Git + Worker Tests (Tier 4)

  • git/bare_repository.py: 23% → 55%
  • worker.py: 17% → 45%
  • Integration test: git operations with real pygit2 repos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions