diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000000000000000000000000000000000000..97c707dae85d518f0a4b69a56c468174055072fd --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,45 @@ +"""Test CLI.""" + +from click.testing import CliRunner +from theia_dumper.cli import list_cols, list_col_items, grab, collection_diff + + +def _test_cli(command, args=None): + """Test a CLI command.""" + print(f"Testing {command}") + runner = CliRunner() + result = runner.invoke(command, args) + print(result) + assert result.exit_code == 0 + + +_test_cli(list_cols) +_test_cli(list_col_items, ["--col_id", "spot-6-7-drs"]) +_test_cli(grab, ["--col_id", "spot-6-7-drs", "--out_json", "/tmp/col.json"]) +_test_cli(grab, ["--col_id", "spot-6-7-drs", "--out_json", "/tmp/col.json", "--pretty"]) +_test_cli( + grab, + [ + "--col_id", + "spot-6-7-drs", + "--item_id", + "SPOT7_MS_201805051026429_SPOT7_P_201805051026429_1", + "--out_json", + "/tmp/item.json", + ], +) +_test_cli( + grab, + [ + "--col_id", + "spot-6-7-drs", + "--item_id", + "SPOT7_MS_201805051026429_SPOT7_P_201805051026429_1", + "--out_json", + "/tmp/item.json", + "--pretty", + ], +) +_test_cli( + collection_diff, ["--remote_id", "spot-6-7-drs", "--col_path", "/tmp/col.json"] +) diff --git a/theia_dumper/__init__.py b/theia_dumper/__init__.py index 4ffdd6069f04aa7dc2e0059ca09d90ca8b0cfc70..dcd6905cc7a2bba931cf4aba4c8439ae22698636 100644 --- a/theia_dumper/__init__.py +++ b/theia_dumper/__init__.py @@ -1,3 +1,3 @@ """Theia dumper package.""" -__version__ = "0.1.2" +__version__ = "0.2.0" diff --git a/theia_dumper/cli.py b/theia_dumper/cli.py index e1a0351661fda00dd1ad6f208394b6174c851785..6902de8df784cfbadaa12351988dbb4a77a56063 100644 --- a/theia_dumper/cli.py +++ b/theia_dumper/cli.py @@ -142,9 +142,11 @@ def list_cols( stac_endpoint: str, ): """List collections.""" - cols = StacTransactionsHandler( - stac_endpoint=stac_endpoint, sign=False - ).client.get_collections() + cols = list( + StacTransactionsHandler( + stac_endpoint=stac_endpoint, sign=False + ).client.get_collections() + ) print(f"Found {len(cols)} collection(s):") for col in sorted(cols, key=lambda x: x.id): print(f"\t{col.id}")