From f87029e4f1bdee23f04be0732c599e8554f23ab0 Mon Sep 17 00:00:00 2001 From: Duncan Gray Date: Thu, 30 Jan 2020 15:36:05 +1100 Subject: [PATCH] get check-code to pass --- eodatasets3/model.py | 5 +++-- eodatasets3/properties.py | 4 +--- tests/integration/test_assemble.py | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/eodatasets3/model.py b/eodatasets3/model.py index 5fd4eb18..222766e5 100644 --- a/eodatasets3/model.py +++ b/eodatasets3/model.py @@ -370,13 +370,14 @@ def datatake_sensing_time(self) -> Optional[str]: datatake_sensing_time = None if "sentinel:sentinel_tile_id" in self.dataset.properties: tile_id = self.dataset.properties.get("sentinel:sentinel_tile_id") - split_tile_id = tile_id.split('_') + split_tile_id = tile_id.split("_") try: - datatake_sensing_time = split_tile_id[-4] + datatake_sensing_time = split_tile_id[-4] except IndexError: pass return datatake_sensing_time + @attr.s(auto_attribs=True, slots=True) class DatasetDoc(EoFields): id: UUID = None diff --git a/eodatasets3/properties.py b/eodatasets3/properties.py index d9972514..39ae1270 100644 --- a/eodatasets3/properties.py +++ b/eodatasets3/properties.py @@ -163,9 +163,7 @@ def producer_check(value): "landsat:station_id": None, } -_SENTINEL_EXTENDED_PROPS = { - "sentinel:sentinel_tile_id": None, -} +_SENTINEL_EXTENDED_PROPS = {"sentinel:sentinel_tile_id": None} class StacPropertyView(collections.abc.Mapping): diff --git a/tests/integration/test_assemble.py b/tests/integration/test_assemble.py index 075b15b2..ccb15d75 100644 --- a/tests/integration/test_assemble.py +++ b/tests/integration/test_assemble.py @@ -239,6 +239,7 @@ def test_dataset_no_measurements(tmp_path: Path): assert doc["label"] == "chipmonk_sightings_2019", "Couldn't override label field" + def test_minimal_s1_dataset(tmp_path: Path): """A minimal dataset with sentinel-1a/b platform/instrument""" with DatasetAssembler(tmp_path) as p: @@ -268,18 +269,23 @@ def test_minimal_s2_dataset_naming(tmp_path: Path): p.producer = "ga.gov.au" p.dataset_version = "1.0.0" p.region_code = "Oz" - p.properties["sentinel:sentinel_tile_id"] = "S2A_OPER_MSI_L1C_TL_SGS__20170822T015626_A011310_T54KYU_N02.05" - p.properties["odc:file_format"] = 'GeoTIFF' + p.properties[ + "sentinel:sentinel_tile_id" + ] = "S2A_OPER_MSI_L1C_TL_SGS__20170822T015626_A011310_T54KYU_N02.05" + p.properties["odc:file_format"] = "GeoTIFF" dataset_id, metadata_path = p.done() - assert p.names.datatake_sensing_time == '20170822T015626' - assert p._dataset_location.parts[-1] == '20170822T015626' - assert p._dataset_location.parts[-2] == '04' + assert p.names.datatake_sensing_time == "20170822T015626" + assert p._dataset_location.parts[-1] == "20170822T015626" + assert p._dataset_location.parts[-2] == "04" with metadata_path.open("r") as f: doc = yaml.safe_load(f) # , Loader=ruamel.yaml.Loader - assert doc["label"] == "ga_s2am_blueberries_1-0-0_Oz_2018-11-04", "Unexpected dataset label" + assert ( + doc["label"] == "ga_s2am_blueberries_1-0-0_Oz_2018-11-04" + ), "Unexpected dataset label" + def test_complain_about_missing_fields(tmp_path: Path, l1_ls8_folder: Path): """