From 8b2e47a41c2710c5bb041c5eadbea9259af777a4 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 4 Jan 2024 17:38:11 +0100 Subject: [PATCH] Fix archive_datasets tests --- isimip_publisher/tests/test_commands.py | 17 ++++++++++++++--- pyproject.toml | 1 - 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/isimip_publisher/tests/test_commands.py b/isimip_publisher/tests/test_commands.py index 0f16afd..39b0785 100644 --- a/isimip_publisher/tests/test_commands.py +++ b/isimip_publisher/tests/test_commands.py @@ -298,13 +298,24 @@ def test_update_datasets(setup, public_files, db, public_datasets, script_runner assert response.stderr.strip().startswith('update_datasets') -def test_archive_datasets(setup, db, public_datasets, script_runner): - response = script_runner.run(['isimip-publisher', 'archive_datasets', 'round/product/sector/model']) +def test_archive_datasets_yes(setup, db, mocker, public_datasets, script_runner): + mocker.patch('builtins.input', return_value='yes') + + response = script_runner.run('isimip-publisher', 'archive_datasets', 'round/product/sector/model') assert response.success, response.stderr - assert not response.stdout + assert response.stdout.strip().startswith('Archiving') assert response.stderr.strip().startswith('archive_datasets') +def test_archive_datasets_no(setup, db, mocker, public_datasets, script_runner): + mocker.patch('builtins.input', return_value='no') + + response = script_runner.run(['isimip-publisher', 'archive_datasets', 'round/product/sector/model']) + assert response.success + assert response.stdout.strip().startswith('Archiving') + assert not response.stderr + + def test_check(setup, public_files, db, public_datasets, script_runner): response = script_runner.run(['isimip-publisher', 'check', 'round/product/sector/model']) assert response.success, response.stderr diff --git a/pyproject.toml b/pyproject.toml index acbb091..6cbc7a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ version = { attr = "isimip_publisher.__version__" } [tool.pytest.ini_options] python_files = "test_*.py" -script_launch_mode = "subprocess" [tool.ruff] target-version = "py38"