Skip to content

Commit

Permalink
Raise an error unsupported lake data in load granule operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nikki-t committed Oct 9, 2024
1 parent 38d278b commit 963a70c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hydrocron/db/load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def granule_handler(event, _):
if ("LakeSP_Prior" in granule_path) & (table_name != constants.SWOT_PRIOR_LAKE_TABLE_NAME):
raise TableMisMatch(f"Error: Cannot load Prior Lake data into table: '{table_name}'")

if ("LakeSP_Obs" in granule_path) | ("LakeSP_Unassigned" in granule_path):
raise TableMisMatch(f"Error: Cannot load Observed or Unassigned Lake data into table: '{table_name}'")

logging.info("Value of load_benchmarking_data is: %s", load_benchmarking_data)

obscure_data = "true" in os.getenv("OBSCURE_DATA").lower()
Expand Down
21 changes: 21 additions & 0 deletions tests/test_hydrocron_database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

"""
==============
test_create_table.py
Expand Down Expand Up @@ -72,3 +74,22 @@ def test_delete_item(hydrocron_dynamo_table):
partition_key=constants.TEST_REACH_ID_VALUE,
sort_key=constants.TEST_REACH_TIME_VALUE)
assert hydrocron_dynamo_table.table.item_count == 686


def test_track_table_mismatch():
"""
Test track ingest table name mismatch with granule UR.
"""
import hydrocron.db.load_data

event = {
"body": {
"granule_path": "s3://podaac-swot-sit-cumulus-protected/SWOT_L2_HR_LakeSP_2.0/SWOT_L2_HR_LakeSP_Obs_020_150_EU_20240825T234434_20240825T235245_PIC0_01.zip",
"table_name": "hydrocron-swot-prior-lake-table",
"load_benchmarking_data": "False",
"track_table": "hydrocron-swot-prior-lake-track-ingest-table"
}
}
with pytest.raises(hydrocron.db.load_data.TableMisMatch) as e:
hydrocron.db.load_data.granule_handler(event, None)
assert str(e.value) == "Error: Cannot load Observed or Unassigned Lake data into table: 'hydrocron-swot-prior-lake-table'"

0 comments on commit 963a70c

Please sign in to comment.