def test_calc_albers_summary_with_storage(summary_store: SummaryStore): summary_store.refresh_all_products() # Should not exist yet. summary = summary_store.get( 'ls8_nbar_albers', year=None, month=None, day=None, ) assert summary is None summary = summary_store.get( 'ls8_nbar_albers', year=2017, month=None, day=None, ) assert summary is None # Calculate overall summary summary = summary_store.get_or_update( 'ls8_nbar_albers', year=2017, month=None, day=None, ) _expect_values( summary, dataset_count=918, footprint_count=918, time_range=Range(begin=datetime(2017, 4, 1, 0, 0, tzinfo=DEFAULT_TZ), end=datetime(2017, 6, 1, 0, 0, tzinfo=DEFAULT_TZ)), newest_creation_time=datetime(2017, 10, 25, 23, 9, 2, 486851, tzinfo=tzutc()), timeline_period='day', # Data spans 61 days in 2017 timeline_count=61, crses={'EPSG:3577'}, # Ingested tiles don't store their size. # TODO: probably should represent this as None instead of zero? size_bytes=0) # get_or_update should now return the cached copy. cached_s = summary_store.get_or_update( 'ls8_nbar_albers', year=2017, month=None, day=None, ) assert cached_s.summary_gen_time is not None assert cached_s.summary_gen_time == summary.summary_gen_time, \ "A new, rather than cached, summary was returned" assert cached_s.dataset_count == summary.dataset_count
def test_calc_empty(summary_store: SummaryStore): summary_store.refresh_all_products() # Should not exist. summary = summary_store.get("ls8_fake_product", year=2006, month=None, day=None) assert summary is None
def test_computed_regions_match_those_summarised(summary_store: SummaryStore): """ The region code for all datasets should be computed identically when done in both SQL and Python. """ summary_store.refresh_all_products() # Loop through all datasets in the test data to check that the the DB and Python # functions give identical region codes. for product in summary_store.index.products.get_all(): region_info = GridRegionInfo.for_product(product, None) for dataset in summary_store.index.datasets.search( product=product.name): ( footprint, alchemy_calculated_region_code, ) = summary_store.get_dataset_footprint_region(dataset.id) python_calculated_region_code = region_info.dataset_region_code( dataset) assert python_calculated_region_code == alchemy_calculated_region_code, ( "Python and DB calculated region codes didn't product the same value. " f"{python_calculated_region_code!r} != {alchemy_calculated_region_code!r}" f"for product {dataset.type.name!r}, dataset {dataset!r}")