Skip to content

COVERAGE: Add tests for fundamental data provider error paths (4 files below 80%) #121

Description

@Finfinder

Description

The fundamental data provider modules have insufficient test coverage, particularly around error-handling paths. The following files have coverage below 80% with specific gaps identified:

File Coverage Missing Tests
bfs_cpi_source.py 74% negative cache, retry path
bls_cpi_source.py 68% retry path, invalid JSON
statcan_cpi_source.py 68% 409 handling, CSV fallback
oecd_sdmx_source.py 79% JSON parsing edge cases

This is a test coverage gap that increases the risk of regressions in the data acquisition layer, which is critical for the accuracy of fundamental analysis results.

Current State

  • All four CPI data source modules have coverage below the project's 80% threshold
  • Error-handling paths (retry, fallback, invalid responses) are untested
  • A failure in any of these modules could silently return stale or incorrect data to the analysis pipeline
  • No tests verify behavior when external APIs return unexpected responses (409, malformed JSON, empty CSV)

Acceptance Criteria

  • bfs_cpi_source.py coverage >= 80% — add tests for negative cache hit and retry path
  • bls_cpi_source.py coverage >= 80% — add tests for retry path and invalid JSON response handling
  • statcan_cpi_source.py coverage >= 80% — add tests for HTTP 409 response and CSV fallback parsing
  • oecd_sdmx_source.py coverage >= 80% — add tests for JSON parsing edge cases (malformed SDMX-JSON, empty datasets)
  • All new tests use mocks for external API calls (no network dependencies)
  • All tests pass in CI on the default branch

References

  • Test coverage gap in fundamental data providers (4 files below 80%)

Additional Context

These data providers feed into the fundamental analysis pipeline. Untested error paths could result in stale or incorrect CPI data being used for market analysis without any indication to the user. Consider using respx or httpx mocking for HTTP-level tests and pytest parametrize for edge case coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend API, domain module, or data-processing topic.technical-debtRefactoring, cleanup, or maintenance debt.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions