GNS-Science / solvis-graphql-api

solvis-graphql-api
GNU Affero General Public License v3.0
1 stars 0 forks source link

Bug: test_cached_ruptures_without_store failing as individual test #55

Closed DrCuriosity closed 5 days ago

DrCuriosity commented 1 month ago

Description

When working on some other refactoring for #51, I tried to execute the following test:

poetry run pytest tests/test_rupture_sorting_function.py::test_cached_ruptures_without_store

Which failed with:

botocore.exceptions.NoCredentialsError: Unable to locate credentials

This leads me to believe that, when run individually, it's not using the internal location resolution. It's possible that the patching on the previous test_cached_ruptures_with_store function is not being cleared down properly.

In cached.py, this makes me think that the ground assumptions for testing have changed since this was originally written:

# we want to use the solvis-store cache normally, override this in testing
RESOLVE_LOCATIONS_INTERNALLY = False  # if DEPLOYMENT_STAGE == 'TEST' else True

The DEPLOYMENT_STAGE value isn't imported or referenced here anymore.

I'm going to investigate and see if I can get the tests in this file to work in a proper unitary fashion.

DrCuriosity commented 1 month ago

Reordering the tests in the file breaks it so yes, there's definite interaction there where there shouldn't be.

DrCuriosity commented 1 month ago

Aha: I think the lru_cache is causing the misbehaviour, because the tests have identical calling parameters, so it's giving us cached results from the first test called when we call matched_rupture_sections_gdf in the subsequent tests.

DrCuriosity commented 1 month ago

Adding a fix for this to #54.