Skip to content

Make the SPM country tests unit tests, with two integration tests against the installed US model #4135

Closed

Description

@anth-volk

Problem

tests/unit/test_country_spm.py took about 14 of the 41 minutes of the pull request workflow's Test job on #4039. make test runs tests/unit in one process under coverage run --branch.

37 of the file's 63 tests ran the installed policyengine-us model through two function-scoped fixtures:

  • real_canonical_country reloaded and revalidated the 26.6 MB SPM forecast for every test (about 0.65 s each), although policyengine-us already caches it.
  • real_http_client built a new Flask app, calculation service, response cache and database row for every test.

Most of those cases repeated one error-to-response mapping for each combination of settings, which stand-in tests can check in milliseconds. One case ran /us/calculate-full, which calculates every variable in the model; it took 48.6 s locally, and 95.0 s when repeated in the same process.

Goal

  • The unit suite holds only fast unit tests, with stand-in simulations and no real model or forecast.
  • The checks that need the installed model are two integration tests, sharing one app and service for the session.
  • /us/calculate-full is checked with a stand-in of the route's behaviour.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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