Skip to content

Commit

Permalink
test: Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared committed Dec 17, 2024
1 parent e68e36c commit 5fa348c
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions tests/integration/test_solve.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
from typer.testing import CliRunner

from ref.cli import app
from ref.database import Database
from ref.models import Dataset, MetricExecution

runner = CliRunner()


def test_solve(esgf_data_dir, config, invoke_cli):
db = Database.from_config(config)

result = invoke_cli(app, ["datasets", "ingest", "--source-type", "cmip6", str(esgf_data_dir)])
invoke_cli(["datasets", "ingest", "--source-type", "cmip6", str(esgf_data_dir)])
assert db.session.query(Dataset).count() == 5

result = invoke_cli(app, ["--verbose", "solve"])
assert "Created metric execution ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1" in result.stdout
assert "Running metric" in result.stdout
result = invoke_cli(["--verbose", "solve"])
assert "Created metric execution ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1" in result.stderr
assert "Running metric" in result.stderr
assert db.session.query(MetricExecution).count() == 2

# Running solve again should not trigger any new metric executions
result = invoke_cli(app, ["--verbose", "solve"])
assert "Created metric execution ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1" not in result.stdout
result = invoke_cli(["--verbose", "solve"])
assert "Created metric execution ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1" not in result.stderr
assert db.session.query(MetricExecution).count() == 2
execution = db.session.query(MetricExecution).filter_by(key="ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1").one()

Expand Down

0 comments on commit 5fa348c

Please sign in to comment.