Closed omad closed 1 year ago
Base: 86.60% // Head: 86.04% // Decreases project coverage by -0.56%
:warning:
Coverage data is based on head (
c0ec914
) compared to base (60daf44
). Patch coverage: 82.40% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Switching back to Draft PR.
I haven't explained the testing changes anywhere near well enough, or documented the new pytest fixtures I've added. I just got excited that all the tests were passing.
Please update this too https://github.com/opendatacube/datacube-explorer#contributing-to-integration-test
Continuing on from work started by @Ariana-B in #479 and myself in https://github.com/opendatacube/odc-tools/pull/524https://github.com/opendatacube/odc-tools/pull/524
This PR completely redoes the way database tests work for Datacube Explorer.
Temporary Docker based PostgreSQL server
postgresql_server
, scope = module)odc_db
of scopemodule
. It creates a new database within the postgres server, named after the test module, and configures ODC to access it via environment variables and temporary configuration files.odc_test_db
, ofmodule
scope, initialises the ODC database structure within the temporary database. It also removes the database after the module is finished.Test fixture data loading
Previously, test data was loaded a little bit all over the place, using a function which was copied into multiple test modules.
This has been replaced by a new fixture called
auto_odc_db
ofmodule
scope, which looks for module variables (namedMETADATA_TYPES
,PRODUCTS
, andDATASETS
), and loads them into the current database. This allows each test module to specify exactly which data it expects to be available.Benefits
In combination, this new setup:
docker
is available.pytest
simultaneously (due to unique docker postgres instances), and multiple test modules simultaneously usingpytest-xdist
, due to unique databases being created per module.These new fixtures have been implemented in a new
cubedash.testutils.database
module, which is loaded as apytest
plugin. My intention, once proven, is to move this test module intodatacube-core
to be available for all downstream ODC based software.:books: Documentation preview :books:: https://datacube-explorer--490.org.readthedocs.build/en/490/