Skip to content

Commit

Permalink
get check-code to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkgray committed Jan 30, 2020
1 parent 0b65a88 commit f87029e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions eodatasets3/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions eodatasets3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 12 additions & 6 deletions tests/integration/test_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit f87029e

Please sign in to comment.