Skip to content

test_budget_window_semi_integration is a unit test, not an integration test #457

@MaxGhenis

Description

@MaxGhenis

Summary

tests/test_budget_window_semi_integration.py is labeled "semi-integration" but exercises nothing real. It uses MockModal, MockDict, a mocked time.sleep, and a fake FastAPI TestClient. The file never touches Modal, network, or any external dependency; it is strictly a unit test and should be labeled as such. There is also no genuine integration coverage for the budget-window orchestration path.

Location

projects/policyengine-api-simulation/tests/test_budget_window_semi_integration.py:1-60

What goes wrong

"""Semi-integration coverage for budget-window gateway and worker seams."""

from fastapi.testclient import TestClient

import src.modal.budget_window_batch as batch_module
import src.modal.budget_window_scheduler as scheduler_module
...

class MockDict:
    def __init__(self, data: dict):
        ...

The test substitutes every external seam (Modal Dicts, FunctionCall, time.sleep) and operates entirely in-process. That is the definition of a unit test, not semi-integration. Calling it "semi-integration" gives false confidence that the budget-window path has real-world coverage — in reality the scheduler's interaction with Modal's actual RPC and Dict semantics (stale reads, timeouts, FunctionCall.from_id edge cases) is not exercised at all.

Suggested fix

  • Rename to test_budget_window_scheduler_unit.py (or similar) to reflect reality.
  • Add a genuine integration test that runs the gateway + a Modal ephemeral app (e.g. via modal run with a lightweight run_simulation stub) and asserts end-to-end status transitions.
  • Gate the integration test on a @pytest.mark.integration marker and a Modal credential, skipped in local/no-credential CI runs.

Severity

Low. Test-quality / coverage-signal issue, not a behavior bug, but meaningful because the budget-window path is new and unauthenticated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions