Skip to content

Commit

Permalink
Refactor: leave instrument out from obs_request when not needed inste…
Browse files Browse the repository at this point in the history
…ad of wildcard
  • Loading branch information
fjugipe committed Feb 9, 2024
1 parent f700ccb commit 36e1a0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions api/routers/edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ async def get_data_location_id(
get_obs_request = dstore.GetObsRequest(
filter=dict(
platform=dstore.Strings(values=[location_id]),
instrument=dstore.Strings(
values=list(map(str.strip, parameter_name.split(","))) if parameter_name else "*"
**(
{"instrument": dstore.Strings(values=list(map(str.strip, parameter_name.split(","))))}
if parameter_name
else {}
),
),
temporal_interval=dstore.TimeInterval(start=range[0], end=range[1]) if range else None,
Expand Down Expand Up @@ -144,7 +146,11 @@ async def get_data_area(
range = get_datetime_range(datetime)
get_obs_request = dstore.GetObsRequest(
filter=dict(
instrument=dstore.Strings(values=list(map(str.strip, parameter_name.split(","))) if parameter_name else "*")
**(
{"instrument": dstore.Strings(values=list(map(str.strip, parameter_name.split(","))))}
if parameter_name
else {}
),
),
spatial_area=dstore.Polygon(
points=[dstore.Point(lat=coord[1], lon=coord[0]) for coord in poly.exterior.coords]
Expand Down
3 changes: 2 additions & 1 deletion api/test/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_get_locations_id_without_parameter_names_query():
mock_getObsRequest.assert_called_once()
m_args = mock_getObsRequest.call_args[0][0]

assert {"*"} == set(m_args.filter["instrument"].values)
assert "instrument" not in m_args.filter
assert {"06260"} == set(m_args.filter["platform"].values)
assert response.status_code == 200
assert response.json() == compare_data

Expand Down

1 comment on commit 36e1a0e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Unit Test Coverage Report
FileStmtsMissCoverMissing
\_\_init\_\_.py00100% 
datastore_pb2.py584621%23–68
datastore_pb2_grpc.py432347%37–52, 85–87, 92–94, 99–101, 106–108, 112–136, 174, 191, 208, 225
dependencies.py31487%23–24, 31, 38
grpc_getter.py8450%12–16
locustfile.py15150%1–31
main.py22386%27, 37, 47
metadata_endpoints.py19479%16, 33–66, 70
formatters
   \_\_init\_\_.py120100% 
   base_formatter.py7186%18
   covjson.py52198%69
routers
   \_\_init\_\_.py00100% 
   edr.py661183%36–59, 113–114, 141–142
   records.py00100% 
test
   \_\_init\_\_.py00100% 
   test_covjson.py530100% 
   test_edr.py900100% 
   utilities.py100100% 
TOTAL48611277% 

API Unit Test Coverage Summary

Tests Skipped Failures Errors Time
15 0 💤 0 ❌ 0 🔥 1.638s ⏱️

Please sign in to comment.