diff --git a/e2e_tests/cli/test_import.py b/e2e_tests/cli/test_import.py index 430ab1855..3cbfce3e5 100644 --- a/e2e_tests/cli/test_import.py +++ b/e2e_tests/cli/test_import.py @@ -4,7 +4,7 @@ from e2e_tests.helpers import ( assert_cli, run_cli_command, - export_and_download_annotations, + export_release, delete_annotation_uuids, list_items, ) @@ -336,12 +336,12 @@ def run_import_test( ) with tempfile.TemporaryDirectory() as tmp_dir_str: actual_annotations_dir = Path(tmp_dir_str) - export_and_download_annotations( - actual_annotations_dir, + release = export_release( annotation_format, # type: ignore local_dataset, config_values, ) + release.download_zip(actual_annotations_dir / "dataset.zip") compare_annotations_export( actual_annotations_dir, expected_annotations_dir, diff --git a/e2e_tests/cli/test_pull.py b/e2e_tests/cli/test_pull.py new file mode 100644 index 000000000..93e4f5eaa --- /dev/null +++ b/e2e_tests/cli/test_pull.py @@ -0,0 +1,36 @@ +from pathlib import Path + +from e2e_tests.helpers import assert_cli, run_cli_command, export_release +from e2e_tests.objects import E2EDataset, ConfigValues + + +def test_pull_with_remote_folder_structure( + local_dataset: E2EDataset, config_values: ConfigValues +): + """ + Test pulling a dataset release with default arguments. + + The remote directory structure should be recreated locally. + """ + pull_dir = Path( + f"{Path.home()}/.darwin/datasets/{config_values.team_slug}/{local_dataset.slug}/images" + ) + expected_filepaths = [ + f"{pull_dir}/image_1", + f"{pull_dir}/image_2", + f"{pull_dir}/dir1/image_3", + f"{pull_dir}/dir1/image_4", + f"{pull_dir}/dir2/image_5", + f"{pull_dir}/dir2/image_6", + f"{pull_dir}/dir1/dir3/image_7", + f"{pull_dir}/dir1/dir3/image_8", + ] + item_type = "single_slotted" + annotation_format = "darwin" + local_dataset.register_read_only_items(config_values, item_type) + release = export_release(annotation_format, local_dataset, config_values) + result = run_cli_command(f"darwin dataset pull {local_dataset.name}:{release.name}") + assert_cli(result, 0) + all_filepaths = list(pull_dir.rglob("*")) + for expected_file in expected_filepaths: + assert Path(expected_file) in all_filepaths diff --git a/e2e_tests/helpers.py b/e2e_tests/helpers.py index b4991d8e8..b4537a476 100644 --- a/e2e_tests/helpers.py +++ b/e2e_tests/helpers.py @@ -3,7 +3,6 @@ from typing import Optional, Union, Sequence from attr import dataclass -from pathlib import Path from darwin.exceptions import DarwinException import datetime import json @@ -193,12 +192,11 @@ def wait_until_items_processed( ) -def export_and_download_annotations( - actual_annotations_dir: Path, +def export_release( annotation_format: str, local_dataset: E2EDataset, config_values: ConfigValues, -) -> None: +) -> Release: """ Creates an export of all items in the given dataset. Waits for the export to finish, then downloads and the annotation files to @@ -261,7 +259,7 @@ def export_and_download_annotations( latest=export_data["latest"], format=export_data.get("format", "json"), ) - release.download_zip(actual_annotations_dir / "dataset.zip") + return release def delete_annotation_uuids(