Skip to content

Cache network responses for testing #217

@khaeru

Description

@khaeru

Periodically we will see test failures like this:

ERROR message_ix_models/tests/tools/test_wb.py::test_get_income_group_codelist - requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://api.worldbank.org/v2/sdmx/rest/codelist/WB/
ERROR message_ix_models/tests/tools/test_wb.py::test_assign_income_groups[R12-population-None] - requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://api.worldbank.org/v2/sdmx/rest/codelist/WB/
ERROR message_ix_models/tests/tools/test_wb.py::test_assign_income_groups[R12-count-None] - requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://api.worldbank.org/v2/sdmx/rest/codelist/WB/
ERROR message_ix_models/tests/tools/test_wb.py::test_assign_income_groups[R12-population-0] - requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://api.worldbank.org/v2/sdmx/rest/codelist/WB/
FAILED message_ix_models/tests/tools/test_wb.py::test_make_map - requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: http://api.worldbank.org/v2/sdmx/rest/codelist/WB/

These occur because of intermittent network issues or server issues on the remote end; in this case the World Bank's SDMX API endpoint.

In order to allow our tests to pass regardless, provide a backup copy of the HTTP response (including headers) and put this in place using a test fixture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ciContinuous integration & testingenhNew features or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions