Skip to content

Commit

Permalink
refactor: assert asset create and update times in loop TDE-1298 (#1181)
Browse files Browse the repository at this point in the history
### Motivation

Refactoring to support TDE-1298 - handle subtests for all created and
updated dates in a similar manner

### Modifications

Changed `test_add_item` to include `assets.visual` `updated` and
`created` attributes in `for` loop.

### Verification

`pytest`
  • Loading branch information
schmidtnz authored Nov 21, 2024
1 parent cfbff10 commit 4bf9fba
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions scripts/stac/imagery/tests/collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ def test_add_item(fake_collection_metadata: CollectionMetadata, fake_linz_slug:
now = any_epoch_datetime()
now_string = format_rfc_3339_datetime_string(now)
collection = ImageryCollection(fake_collection_metadata, fixed_now_function(now), fake_linz_slug)
asset_created_datetime = any_epoch_datetime_string()
asset_updated_datetime = any_epoch_datetime_string()
asset_datetimes = {
"created": any_epoch_datetime_string(),
"updated": any_epoch_datetime_string(),
}
item = ImageryItem(
"BR34_5000_0304",
now_string,
STACAsset(
**{
"href": "any href",
"file:checksum": "any checksum",
"created": asset_created_datetime,
"updated": asset_updated_datetime,
"created": asset_datetimes["created"],
"updated": asset_datetimes["updated"],
}
),
any_stac_processing(),
Expand Down Expand Up @@ -162,11 +164,8 @@ def test_add_item(fake_collection_metadata: CollectionMetadata, fake_linz_slug:
with subtests.test(msg=f"item properties.{property_name}"):
assert item.stac["properties"][property_name] == now_string

with subtests.test(msg="item assets.visual.created"):
assert item.stac["assets"]["visual"]["created"] == asset_created_datetime

with subtests.test(msg="item assets.visual.updated"):
assert item.stac["assets"]["visual"]["updated"] == asset_updated_datetime
with subtests.test(msg=f"item assets.visual.{property_name}"):
assert item.stac["assets"]["visual"][property_name] == asset_datetimes[property_name]


def test_write_collection(fake_collection_metadata: CollectionMetadata, fake_linz_slug: str) -> None:
Expand Down

0 comments on commit 4bf9fba

Please sign in to comment.