opendatacube / datacube-explorer

Web-based exploration of Open Data Cube collections
Apache License 2.0
54 stars 31 forks source link

Replace Datacube Explorer Database Test Infrastructure #490

Closed omad closed 1 year ago

omad commented 1 year ago

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

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 of module scope, which looks for module variables (named METADATA_TYPES, PRODUCTS, and DATASETS), 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:

These new fixtures have been implemented in a new cubedash.testutils.database module, which is loaded as a pytest plugin. My intention, once proven, is to move this test module into datacube-core to be available for all downstream ODC based software.


:books: Documentation preview :books:: https://datacube-explorer--490.org.readthedocs.build/en/490/

codecov[bot] commented 1 year ago

Codecov Report

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.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #490 +/- ## =========================================== - Coverage 86.60% 86.04% -0.57% =========================================== Files 23 24 +1 Lines 3017 3188 +171 =========================================== + Hits 2613 2743 +130 - Misses 404 445 +41 ``` | [Impacted Files](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube) | Coverage Δ | | |---|---|---| | [cubedash/summary/\_summarise.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvc3VtbWFyeS9fc3VtbWFyaXNlLnB5) | `96.05% <ø> (ø)` | | | [cubedash/testutils/database.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvdGVzdHV0aWxzL2RhdGFiYXNlLnB5) | `68.68% <68.68%> (ø)` | | | [cubedash/\_stac.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvX3N0YWMucHk=) | `86.53% <85.26%> (-5.11%)` | :arrow_down: | | [cubedash/\_api.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvX2FwaS5weQ==) | `95.91% <93.33%> (-1.23%)` | :arrow_down: | | [cubedash/\_audit.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvX2F1ZGl0LnB5) | `92.95% <100.00%> (+1.78%)` | :arrow_up: | | [cubedash/\_filters.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvX2ZpbHRlcnMucHk=) | `89.75% <100.00%> (+0.31%)` | :arrow_up: | | [cubedash/\_utils.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvX3V0aWxzLnB5) | `89.18% <100.00%> (+1.98%)` | :arrow_up: | | [cubedash/summary/\_stores.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvc3VtbWFyeS9fc3RvcmVzLnB5) | `92.16% <100.00%> (+0.01%)` | :arrow_up: | | [cubedash/warmup.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvd2FybXVwLnB5) | `65.64% <100.00%> (+0.80%)` | :arrow_up: | | [cubedash/summary/\_schema.py](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-Y3ViZWRhc2gvc3VtbWFyeS9fc2NoZW1hLnB5) | `80.67% <0.00%> (-0.85%)` | :arrow_down: | | ... and [5 more](https://codecov.io/gh/opendatacube/datacube-explorer/pull/490/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

omad commented 1 year ago

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.

pindge commented 1 year ago

Please update this too https://github.com/opendatacube/datacube-explorer#contributing-to-integration-test