Skip to content

Commit

Permalink
Feature/issue 13 - Add SWORD version to API response (#121)
Browse files Browse the repository at this point in the history
* Include units in API JSON and CSV response

* Update existing unit tests for SWOT shapefile units

* Define a unit test for adding units and load test data from file

* Fix whitespace and line continuation

* Add sword_version to API response fields

* Update changelog with issue

* Update changelog with issue

---------

Co-authored-by: Frank Greguska <[email protected]>
  • Loading branch information
nikki-t and frankinspace authored Mar 28, 2024
1 parent f31ff11 commit 5aa086b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- Issue 13 - Add SWORD version from shp.xml to DB entries
- Issue 85 - Add variable units to API response
- Issue 78 - Use a VPC endpoint and policies to access DynamoDB
- Issue 91 - Add CORS headers to API responses
Expand Down
4 changes: 2 additions & 2 deletions hydrocron/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
'p_wse', 'p_wse_var', 'p_width', 'p_wid_var', 'p_n_nodes', 'p_dist_out',
'p_length', 'p_maf', 'p_dam_id', 'p_n_ch_max', 'p_n_ch_mod', 'p_low_slp',
'cycle_id', 'pass_id', 'continent_id', 'range_start_time', 'range_end_time',
'crid', 'geometry'
'crid', 'geometry', 'sword_version'
]

NODE_ALL_COLUMNS = [
Expand All @@ -154,5 +154,5 @@
'p_wse', 'p_wse_var', 'p_width', 'p_wid_var', 'p_dist_out', 'p_length',
'p_dam_id', 'p_n_ch_max', 'p_n_ch_mod',
'cycle_id', 'pass_id', 'continent_id', 'range_start_time', 'range_end_time',
'crid', 'geometry'
'crid', 'geometry', 'sword_version'
]
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_timeseries_lambda_handler_geojson(hydrocron_api):
"start_time": "2023-06-04T00:00:00Z",
"end_time": "2023-06-23T00:00:00Z",
"output": "geojson",
"fields": "reach_id,time_str,wse"
"fields": "reach_id,time_str,wse,sword_version"
}
}

Expand All @@ -35,7 +35,7 @@ def test_timeseries_lambda_handler_geojson(hydrocron_api):
assert result['status'] == '200 OK' and \
result['results']['geojson'] == {'type': 'FeatureCollection', 'features': [
{'id': '0', 'properties': {'reach_id': '71224100223', 'time_str': '2023-06-10T19:39:43Z',
'wse': '286.2983', 'wse_units': 'm'}, 'geometry': {'coordinates':
'wse': '286.2983', 'sword_version': '15', 'wse_units': 'm'}, 'geometry': {'coordinates':
[[-95.564991, 50.223686], [-95.564559, 50.223479],
[-95.564133, 50.223381],
[-95.563713, 50.22339], [-95.563296, 50.223453],
Expand Down Expand Up @@ -268,15 +268,15 @@ def test_timeseries_lambda_handler_csv(hydrocron_api):
"start_time": "2023-06-04T00:00:00Z",
"end_time": "2023-06-23T00:00:00Z",
"output": "csv",
"fields": "reach_id,time_str,wse,geometry"
"fields": "reach_id,time_str,wse,sword_version,geometry"
}
}

context = "_"
result = hydrocron.api.controllers.timeseries.lambda_handler(event, context)
assert result['status'] == '200 OK'
assert result['results']['csv'] == ('reach_id,time_str,wse,geometry,wse_units\n' \
'71224100223,2023-06-10T19:39:43Z,286.2983,"LINESTRING (-95.564991 50.223686, ' \
assert result['results']['csv'] == ('reach_id,time_str,wse,sword_version,geometry,wse_units\n' \
'71224100223,2023-06-10T19:39:43Z,286.2983,15,"LINESTRING (-95.564991 50.223686, ' \
'-95.564559 50.223479, -95.564133 50.223381, -95.563713 50.22339, -95.563296 ' \
'50.223453, -95.562884 50.223624, -95.562473 50.223795, -95.562062 50.223966, ' \
'-95.56165 50.224137, -95.561242 50.224362, -95.560917 50.224585, -95.560595 ' \
Expand Down

0 comments on commit 5aa086b

Please sign in to comment.