Issue Description
Background
The dataviewer backend has 46 source files in data-management/viewer/backend/src/ and 29 test files in data-management/viewer/backend/tests/. While this is the most mature test suite outside of training/, coverage gaps remain. The existing CI workflow (dataviewer-backend-pytests.yml) already uploads coverage to Codecov with the pytest-dataviewer flag.
This issue focuses on improving coverage of untested or under-tested source files to contribute toward the OpenSSF Silver ≥50% overall coverage threshold.
Current Infrastructure
- CI workflow:
.github/workflows/dataviewer-backend-pytests.yml — runs uv run pytest -v --cov=src --cov-report=xml
- Codecov flag:
pytest-dataviewer with paths: ["data-management/viewer/backend/src/"]
- Test dependencies: pytest, pytest-asyncio, pytest-cov, httpx, hypothesis, schemathesis (in
pyproject.toml)
- Pytest config:
asyncio_mode = "auto", testpaths = ["tests"]
- No
[tool.coverage.run] in backend pyproject.toml — coverage measured via CLI flags only
Coverage Gap Analysis Needed
Identify which of the 46 source files have no corresponding test files or low coverage:
- Compare
src/ file list against tests/ file list
- Run local coverage report to identify files below threshold
- Prioritize by: (1) business logic complexity, (2) API surface area, (3) error handling paths
Suggested Fix
1. Generate Coverage Gap Report
cd data-management/viewer/backend
uv run pytest -v --cov=src --cov-report=term-missing --cov-report=html
Review htmlcov/index.html to identify uncovered modules.
2. Add Missing Test Files
For each untested source module, create a corresponding test file following existing patterns:
- Test file:
tests/test_{module_name}.py
- Class-based grouping:
class TestModuleName:
- Mock external deps: Azure SDK, filesystem, auth providers
- Test public API surfaces only
3. Add Coverage Configuration
Add a [tool.coverage.run] section to data-management/viewer/backend/pyproject.toml:
[tool.coverage.run]
source = ["src"]
branch = true
omit = ["src/**/conftest.py", "src/**/__init__.py"]
[tool.coverage.report]
show_missing = true
precision = 2
4. Validate
- All new tests pass without live Azure services
- Coverage report shows improvement over baseline
- CI workflow continues to upload accurate coverage data
Acceptance Criteria
Implementation Notes
Related Issues
OpenSSF IDs: regression_tests_added50
Issue Description
Background
The dataviewer backend has 46 source files in
data-management/viewer/backend/src/and 29 test files indata-management/viewer/backend/tests/. While this is the most mature test suite outside oftraining/, coverage gaps remain. The existing CI workflow (dataviewer-backend-pytests.yml) already uploads coverage to Codecov with thepytest-dataviewerflag.This issue focuses on improving coverage of untested or under-tested source files to contribute toward the OpenSSF Silver ≥50% overall coverage threshold.
Current Infrastructure
.github/workflows/dataviewer-backend-pytests.yml— runsuv run pytest -v --cov=src --cov-report=xmlpytest-dataviewerwithpaths: ["data-management/viewer/backend/src/"]pyproject.toml)asyncio_mode = "auto",testpaths = ["tests"][tool.coverage.run]in backendpyproject.toml— coverage measured via CLI flags onlyCoverage Gap Analysis Needed
Identify which of the 46 source files have no corresponding test files or low coverage:
src/file list againsttests/file listSuggested Fix
1. Generate Coverage Gap Report
cd data-management/viewer/backend uv run pytest -v --cov=src --cov-report=term-missing --cov-report=htmlReview
htmlcov/index.htmlto identify uncovered modules.2. Add Missing Test Files
For each untested source module, create a corresponding test file following existing patterns:
tests/test_{module_name}.pyclass TestModuleName:3. Add Coverage Configuration
Add a
[tool.coverage.run]section todata-management/viewer/backend/pyproject.toml:4. Validate
Acceptance Criteria
[tool.coverage.run]section added to backendpyproject.tomlpytest-dataviewerCodecov flag shows measurable coverage improvementImplementation Notes
from __future__ import annotations,_LOGGERnaming,monkeypatchoverunittest.mock.patchDepends(require_auth)andDepends(require_csrf_token)must be overridden in test fixtureshttpx.AsyncClientwithapptransport per existing test patternsRelated Issues
OpenSSF IDs:
regression_tests_added50