def test_uninitialised_search_page(empty_client: FlaskClient, summary_store: SummaryStore): # Populate one product, so they don't get the usage error message ("run cubedash generate") summary_store.refresh("ls7_nbar_albers") # Then load a completely uninitialised product. html = get_html(empty_client, "/datasets/ls7_nbar_scene") search_results = html.find(".search-result a") assert len(search_results) == 4
def test_calc_albers_summary_with_storage(summary_store: SummaryStore): # 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 # We don't want it to add a few minutes overlap buffer, # as we add datasets and refresh immediately. summary_store.dataset_overlap_carefulness = timedelta(seconds=0) # Calculate overall summary _, summary = summary_store.refresh("ls8_nbar_albers") _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, 486_851, 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, ) original = summary_store.get("ls8_nbar_albers", 2017) # It should now return the same copy, not rebuild it. summary_store.refresh("ls8_nbar_albers") cached_s = summary_store.get("ls8_nbar_albers", 2017) assert original is not cached_s assert cached_s.dataset_count == original.dataset_count assert cached_s.summary_gen_time is not None assert (cached_s.summary_gen_time == original.summary_gen_time ), "A new, rather than cached, summary was returned"
def test_uninitialised_overview(unpopulated_client: FlaskClient, summary_store: SummaryStore): # Populate one product, so they don't get the usage error message ("run cubedash generate") # Then load an unpopulated product. summary_store.refresh("ls7_nbar_albers") html = get_html(unpopulated_client, "/ls7_nbar_scene/2017") # The page should load without error, but will display 'unknown' fields assert html.find( "h2", first=True).text == "ls7_nbar_scene: Landsat 7 NBAR 25 metre" assert "Unknown number of datasets" in html.text assert "No data: not yet generated" in html.text
def test_add_no_periods(summary_store: SummaryStore): """ All the get/update methods should work on products with no datasets. """ result, summary = summary_store.refresh("ga_ls8c_level1_3") assert result == GenerateResult.CREATED assert summary.dataset_count == 0 assert summary_store.get("ga_ls8c_level1_3", 2015, 7, 4).dataset_count == 0 result, summary = summary_store.refresh("ga_ls8c_level1_3") assert result == GenerateResult.NO_CHANGES assert summary.dataset_count == 0 assert summary_store.get("ga_ls8c_level1_3").dataset_count == 0 assert summary_store.get("ga_ls8c_level1_3", 2015, 7, None) is None
def test_uninitialised_product(empty_client: FlaskClient, summary_store: SummaryStore): """ An unsummarised product should still be viewable on the product page. (but should be described as not summarised) """ # Populate one product, so they don't get the usage error message ("run cubedash generate") # Then load an unpopulated product. summary_store.refresh("ls7_nbar_albers") html = get_html(empty_client, "/products/ls7_nbar_scene") # The page should load without error, but will mention its lack of information assert html.find("h2", first=True).text == "ls7_nbar_scene" assert ("Product not summarised" in one_element(html, ".header-stat-information").text) # ... and a product that we populated does not have the message: html = get_html(empty_client, "/products/ls7_nbar_albers") assert ("Product not summarised" not in one_element(html, ".header-stat-information").text)