Skip to content

Commit

Permalink
test: add unit tests for levels combination
Browse files Browse the repository at this point in the history
  • Loading branch information
fjugipe committed Nov 19, 2024
1 parent 71c92cf commit 779c6a4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api/test/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,33 @@ def test_get_data_with_lowercase_period_range_without_existing_data():

assert response.status_code == 404
assert response.json() == {"detail": "Requested data not found."}


def test_get_data_with_combination_levels_filtering():
with patch("routers.edr.get_obs_request") as mock_get_obs_request:

# Load with random test data for making a mock_obs_request
test_data = load_json("test/test_data/test_coverages_proto.json")
mock_get_obs_request.return_value = create_mock_obs_response(test_data)

response = client.get("/collections/observations/locations/0-20000-0-06260?levels=R6/0.0/0.1, 1.5/1.8, 10")

m_args = mock_get_obs_request.call_args[0][0]

assert response.status_code == 200
assert m_args.filter["level"].values == ["0", "10", "20", "30", "40", "50", "150/180", "1000"]


def test_get_data_with_combination_periods_filtering():
with patch("routers.edr.get_obs_request") as mock_get_obs_request:

# Load with random test data for making a mock_obs_request
test_data = load_json("test/test_data/test_coverages_proto.json")
mock_get_obs_request.return_value = create_mock_obs_response(test_data)

response = client.get("/collections/observations/locations/0-20000-0-06260?periods=PT0S, PT1M/PT10M")

m_args = mock_get_obs_request.call_args[0][0]

assert response.status_code == 200
assert m_args.filter["period"].values == ["0", "60/600"]

1 comment on commit 779c6a4

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage

Unit Test Coverage Report
FileStmtsMissCoverMissing
__init__.py00100% 
datastore_pb2.py614821%34–81
datastore_pb2_grpc.py542750%15–16, 19, 65–80, 121–123, 128–130, 135–137, 142–144, 148–173, 219, 246, 273, 300
export_metrics.py100100% 
grpc_getter.py201145%15–19, 23–26, 30–32, 36–38
locustfile.py15150%1–31
main.py43784%45, 50, 60, 70–71, 81–82
metadata_endpoints.py663252%45–54, 58, 85, 100–220, 224
response_classes.py50100% 
utilities.py1753978%21, 39, 46, 68–71, 79–90, 95–102, 122, 126, 128, 156, 162, 180, 244–250, 254–256, 286, 290, 312, 317
custom_geo_json
   edr_feature_collection.py60100% 
formatters
   __init__.py110100% 
   covjson.py60198%91
   geojson.py21290%27, 52
openapi
   custom_dimension_examples.py40100% 
   edr_query_parameter_descriptions.py110100% 
   openapi_examples.py130100% 
routers
   __init__.py00100% 
   edr.py101496%348–349, 438–439
   feature.py471960%99–132, 148–153, 159–181
TOTAL72320572% 

Title Coverage Tests Skipped Failures Errors Time
API Unit Tests Coverage 32 0 💤 0 ❌ 0 🔥 1.896s ⏱️
Ingest Unit Tests Coverage 16 0 💤 0 ❌ 0 🔥 1m 43s ⏱️

Please sign in to comment.