from cubedash.summary._schema import METADATA as CUBEDASH_METADATA from cubedash.warmup import find_examples_of_all_public_urls from datacube.drivers.postgres import PostgresDb from datacube.drivers.postgres._core import METADATA as ODC_SCHEMA_METADATA from datacube.index import Index from datacube.index.hl import Doc2Dataset from datacube.model import Dataset from datacube.utils import read_documents from digitalearthau.testing import factories # Use module-scoped databases, as it takes a while to populate with # our data, and we're treating it as read-only in tests. # -> Note: Since we're reusing the default config unchanged, we can't use the # default index/dea_index fixtures, as they'll override data from # the same db. module_vanilla_db = factories.db_fixture("local_config", scope="module") @pytest.fixture(scope="module") def module_db(module_vanilla_db: PostgresDb) -> PostgresDb: # Set all the tables to unlogged for faster perf. _make_all_tables_unlogged(module_vanilla_db._engine, ODC_SCHEMA_METADATA) return module_vanilla_db def _make_all_tables_unlogged(engine, metadata: sqlalchemy.MetaData): """ Set all tables in this alchemy metadata to unlogged. Make them faster, but data is lost on crashes. Which is a good trade-off for tests.
from cubedash.summary import SummaryStore, show from cubedash.summary import _extents from datacube.index import Index from datacube.index.hl import Doc2Dataset from datacube.model import Dataset from datacube.utils import read_documents from requests_html import HTML pytest_plugins = "digitalearthau.testing.plugin" # Use module-scoped databases, as it takes a while to populate with # our data, and we're treating it as read-only in tests. # -> Note: Since we're reusing the default config unchanged, we can't use the # default index/dea_index fixtures, as they'll override data from # the same db. module_db = factories.db_fixture('local_config', scope='module') module_index = factories.index_fixture('module_db', scope='module') module_dea_index = factories.dea_index_fixture('module_index', scope='module') @pytest.fixture(scope='function') def summary_store(module_dea_index: Index) -> SummaryStore: SummaryStore.create(module_dea_index, init_schema=False).drop_all() module_dea_index.close() store = SummaryStore.create(module_dea_index, init_schema=True) return store @pytest.fixture(scope='function') def summariser(summary_store: SummaryStore): return summary_store._summariser