|
2 | 2 |
|
3 | 3 | from flask.testing import FlaskClient
|
4 | 4 | import cubedash
|
5 |
| -from cubedash.summary import SummaryStore |
| 5 | +from pathlib import Path |
6 | 6 |
|
| 7 | +from cubedash.summary import SummaryStore |
| 8 | +from datacube.index.hl import Doc2Dataset |
| 9 | +from datacube.utils import read_documents |
7 | 10 | from integration_tests.asserts import (
|
8 | 11 | get_html
|
9 | 12 | )
|
@@ -53,6 +56,36 @@ def test_hide_products_audit_page_display(app_configured_client: FlaskClient, to
|
53 | 56 | assert indexed_product_count == str(total_indexed_products_count)
|
54 | 57 | assert str(total_indexed_products_count - 5) in h2
|
55 | 58 |
|
| 59 | + |
| 60 | +TEST_DATA_DIR = Path(__file__).parent / "data" |
| 61 | + |
| 62 | + |
| 63 | +@pytest.fixture(scope="module", autouse=True) |
| 64 | +def populate_index(dataset_loader, module_dea_index): |
| 65 | + """ |
| 66 | + Index populated with example datasets. Assumes our tests wont modify the data! |
| 67 | +
|
| 68 | + It's module-scoped as it's expensive to populate. |
| 69 | + """ |
| 70 | + dataset_count = 0 |
| 71 | + create_dataset = Doc2Dataset(module_dea_index) |
| 72 | + for _, s2_dataset_doc in read_documents(TEST_DATA_DIR / "ls5_fc_albers-sample.yaml"): |
| 73 | + try: |
| 74 | + dataset, err = create_dataset( |
| 75 | + s2_dataset_doc, "file://example.com/test_dataset/" |
| 76 | + ) |
| 77 | + assert dataset is not None, err |
| 78 | + created = module_dea_index.datasets.add(dataset) |
| 79 | + assert created.type.name == "ls5_fc_albers" |
| 80 | + dataset_count += 1 |
| 81 | + except AttributeError as ae: |
| 82 | + assert dataset_count == 5 |
| 83 | + print(ae) |
| 84 | + assert dataset_count == 5 |
| 85 | + return module_dea_index |
| 86 | + |
| 87 | + |
| 88 | +def test_hide_products_audit_bulk_dataset_display(app_configured_client: FlaskClient, total_indexed_products_count): |
56 | 89 | html = get_html(app_configured_client, "/audit/dataset-counts")
|
57 | 90 | hidden_product_count = html.find("span.hidden-product-count", first=True).text
|
58 | 91 | assert hidden_product_count == '5'
|
|
0 commit comments