Skip to content

Commit

Permalink
fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariana Barzinpour committed Nov 21, 2024
1 parent e097d12 commit 503ad74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
19 changes: 8 additions & 11 deletions integration_tests/test_pages_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]


Expand Down Expand Up @@ -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?"

Expand Down
20 changes: 10 additions & 10 deletions integration_tests/test_raw_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import datacube.scripts.cli_app
import pytest
from click.testing import CliRunner
from flask.testing import FlaskClient

METADATA_TYPES = [
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand Down

0 comments on commit 503ad74

Please sign in to comment.