From 503ad747ca095c0705bd060fb3b9a353d7cf3547 Mon Sep 17 00:00:00 2001 From: Ariana Barzinpour Date: Thu, 21 Nov 2024 02:45:17 +0000 Subject: [PATCH] fix some tests --- integration_tests/test_pages_render.py | 19 ++++++++----------- integration_tests/test_raw_yaml.py | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/integration_tests/test_pages_render.py b/integration_tests/test_pages_render.py index fcb80009c..804f4a12b 100644 --- a/integration_tests/test_pages_render.py +++ b/integration_tests/test_pages_render.py @@ -7,21 +7,19 @@ from flask.testing import FlaskClient from sqlalchemy import text -from cubedash.summary import SummaryStore, _schema +from cubedash.summary import SummaryStore METADATA_TYPES = [ - "metadata/landsat_l1_scene.yaml", + "metadata/eo3_metadata.yaml", + "metadata/eo3_landsat_ard.odc-type.yaml", ] PRODUCTS = [ - "products/dsm1sv10.odc-product.yaml", - "products/wofs_albers.yaml", - "products/ls7_scenes.odc-product.yaml", - "products/ls7_nbart_albers.odc-product.yaml", - "products/ls8_scenes.odc-product.yaml", - "products/ls8_nbart_albers.odc-product.yaml", + "products/ga_ls7e_ard_3.odc-product.yaml", + "products/ga_ls8c_ard_3.odc-product.yaml", + "products/esa_s2_l2a.product.yaml", ] DATASETS = [ - "datasets/wofs-albers-sample.yaml.gz", + "datasets/ga_ls7e_ard_3-sample.yaml", ] @@ -96,10 +94,9 @@ def test_allows_null_product_fixed_fields( ), "There's no summarised products to test" # AND there's some with null fixed_metadata (ie. pre-Explorer0-EO3-update) - # with _utils.alchemy_engine(odc_test_db.index).begin() as conn: with odc_test_db.index._active_connection() as conn: update_count = conn.execute( - text(f"update {_schema.PRODUCT.fullname} set fixed_metadata = null") + text("update cubedash.product set fixed_metadata = null") ).rowcount assert update_count > 0, "There were no test products to update?" diff --git a/integration_tests/test_raw_yaml.py b/integration_tests/test_raw_yaml.py index 567f42cb7..340cb5026 100644 --- a/integration_tests/test_raw_yaml.py +++ b/integration_tests/test_raw_yaml.py @@ -9,6 +9,7 @@ import datacube.scripts.cli_app import pytest +from click.testing import CliRunner from flask.testing import FlaskClient METADATA_TYPES = [ @@ -100,31 +101,30 @@ def dataset_yaml_from_raw(client: FlaskClient): return f.name -# Why are we testing core scripts here?? -def test_update_type(type_yaml_from_raw, clirunner): - result = clirunner( +@pytest.mark.parametrize("env_name", ("datacube",), indirect=True) +def test_update_type(type_yaml_from_raw): + result = CliRunner().invoke( datacube.scripts.cli_app.cli, [ "metadata", "update", type_yaml_from_raw, ], - expect_success=False, ) assert 'Updated "eo_plus"\n' in result.output assert result.exit_code == 0 -def test_update_product(product_yaml_from_raw, clirunner): - result = clirunner( +@pytest.mark.parametrize("env_name", ("datacube",), indirect=True) +def test_update_product(product_yaml_from_raw): + result = CliRunner().invoke( datacube.scripts.cli_app.cli, [ "product", "update", product_yaml_from_raw, ], - expect_success=False, ) assert 'Updated "ls5_fc_albers"\n' in result.output @@ -134,15 +134,15 @@ def test_update_product(product_yaml_from_raw, clirunner): assert result.exit_code == 0 -def test_update_dataset(dataset_yaml_from_raw, clirunner): - result = clirunner( +@pytest.mark.parametrize("env_name", ("datacube",), indirect=True) +def test_update_dataset(dataset_yaml_from_raw): + result = CliRunner().invoke( datacube.scripts.cli_app.cli, [ "dataset", "update", dataset_yaml_from_raw, ], - expect_success=False, ) assert (