From c187b779e3b0d483fbaa44e94903dfe623d3f772 Mon Sep 17 00:00:00 2001 From: Jeremy Hooke Date: Fri, 20 May 2022 10:04:50 +1000 Subject: [PATCH] Update tests for metadata as a folder sibling --- eodatasets3/prepare/sentinel_l1_prepare.py | 2 +- .../integration/prepare/test_prepare_sentinel_l1.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/eodatasets3/prepare/sentinel_l1_prepare.py b/eodatasets3/prepare/sentinel_l1_prepare.py index e45d48ff..8330ebf2 100644 --- a/eodatasets3/prepare/sentinel_l1_prepare.py +++ b/eodatasets3/prepare/sentinel_l1_prepare.py @@ -192,7 +192,7 @@ def prepare_and_write( ) -> Tuple[DatasetDoc, Path]: if embed_location is None: # Default to embedding the location if they're not in the same folder. - embed_location = dataset_location.parent != output_yaml.parent + embed_location = output_yaml.parent not in dataset_location.parents _LOG.debug( "Auto-embed location? %s: %s %s %s", "Yes" if embed_location else "No", diff --git a/tests/integration/prepare/test_prepare_sentinel_l1.py b/tests/integration/prepare/test_prepare_sentinel_l1.py index 8395b906..eedccd82 100644 --- a/tests/integration/prepare/test_prepare_sentinel_l1.py +++ b/tests/integration/prepare/test_prepare_sentinel_l1.py @@ -379,14 +379,11 @@ def dataset_input_output(request, tmp_path): if input_dataset_path.is_dir(): shutil.copytree(input_dataset_path, unique_in_path) - # A folder input expects a metadata file inside. - expected_metadata_path = ( - tmp_path / input_dataset_path.name / expected_metadata_name - ) else: shutil.copy(input_dataset_path, unique_in_path) - # A file expects a sibling metadata path. - expected_metadata_path = tmp_path / expected_metadata_name + + # A file expect a sibling metadata path. + expected_metadata_path = tmp_path / expected_metadata_name return ( unique_in_path, @@ -404,9 +401,7 @@ def test_filter_folder_structure_info( expected_metadata_path, ) = dataset_input_output - metadata_offset = expected_metadata_path.relative_to( - input_dataset_path if input_dataset_path.is_dir() else input_dataset_path.parent - ) + metadata_offset = expected_metadata_path.relative_to(input_dataset_path.parent) input_folder = tmp_path / "inputs"