Skip to content

Integration tests with mocked APIs — fixture-based test coverage for SEC, Yahoo, FRED #28

@DogInfantry

Description

@DogInfantry

Summary

Add integration tests that exercise the full data fetch and pipeline flow using pre-recorded API fixture responses, without making live network calls. This is the missing layer between unit tests (which already exist) and end-to-end pipeline runs.

Motivation

Unit tests for parsing and rendering exist, but there are no integration tests that verify the full data-fetch → parse → compute → render chain. Without integration tests, any API schema change silently breaks the pipeline. Mocked integration tests also allow CI to run without live API keys, which is critical for public contributors and a standard expectation for any production-grade Python project.

Implementation Approach

Use responses or pytest-recording (VCR cassettes) to record and replay HTTP interactions:

# tests/integration/test_pipeline_integration.py
import responses

@responses.activate
def test_full_pipeline_aapl(fixture_sec_response, fixture_yahoo_response):
    responses.add(responses.GET, SEC_XBRL_URL, json=fixture_sec_response)
    responses.add(responses.GET, YAHOO_URL, json=fixture_yahoo_response)
    result = run_pipeline(ticker='AAPL', as_of='2026-03-31')
    assert result['rating'] in ('Buy', 'Hold', 'Sell')
    assert result['target_price'] > 0
    assert 'html' in result['outputs']

Fixture Files to Create

tests/
├── fixtures/
│   ├── sec_xbrl_aapl.json       # Sample EDGAR XBRL response
│   ├── yahoo_summary_aapl.json  # Sample Yahoo Finance summary
│   ├── fred_cpi.json            # Sample FRED CPI series
│   └── ecb_sdmx.xml             # Sample ECB SDMX response
└── integration/
    ├── test_pipeline_integration.py
    ├── test_valuation_integration.py
    └── test_reporting_integration.py

Acceptance Criteria

  • Integration test suite in tests/integration/ using fixture responses (no live API calls)
  • Fixtures committed for SEC EDGAR, Yahoo Finance, and FRED
  • Full pipeline run tested end-to-end with AAPL fixture data
  • Integration tests tagged @pytest.mark.integration and included in CI by default
  • CI passes with zero live API calls (SEC_USER_AGENT set to dummy value in workflow)
  • README testing section updated to document pytest -m integration command

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions