Skip to content

Commit

Permalink
Hardwrap lines to 80 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
b-yogesh committed Sep 13, 2024
1 parent 0eae395 commit 9b3f312
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
25 changes: 16 additions & 9 deletions test/webapi/statistics/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_fetch_post_statistics_missing_time_with_time_dimension_dataset(self):
method="POST",
body='{"type": "Point", "coordinates": [1.768, 51.465]}',
)
self.assertBadRequestResponse(response, "Missing query parameter 'time'")
self.assertBadRequestResponse(response, "Missing " "query parameter 'time'")

def test_fetch_post_statistics_missing_time_without_time_dimension_dataset(self):
response = self.fetch(
Expand All @@ -44,7 +44,8 @@ def test_fetch_post_statistics_with_time_without_time_dimension_dataset(self):
)
self.assertBadRequestResponse(
response,
"Query parameter 'time' must not be given since dataset does not contain a 'time' dimension",
"Query parameter 'time' must not be given since "
"dataset does not contain a 'time' dimension",
)

def test_fetch_post_statistics_invalid_geometry(self):
Expand All @@ -53,11 +54,14 @@ def test_fetch_post_statistics_invalid_geometry(self):
method="POST",
body="[1.768, 51.465]",
)
self.assertBadRequestResponse(response, "Invalid GeoJSON geometry encountered")
self.assertBadRequestResponse(
response, "Invalid " "GeoJSON geometry encountered"
)

def test_fetch_get_statistics_ok(self):
response = self.fetch(
"/statistics/demo/conc_chl?lat=1.786&lon=51.465&time=2017-01-16+10:09:21",
"/statistics/demo/conc_chl?"
"lat=1.786&lon=51.465&time=2017-01-16+10:09:21",
method="GET",
)
self.assertResponseOK(response)
Expand All @@ -66,29 +70,32 @@ def test_fetch_get_statistics_missing_time_with_time_dimension_dataset(self):
response = self.fetch(
"/statistics/demo/conc_chl?lat=1.786&lon=51.465", method="GET"
)
self.assertBadRequestResponse(response, "Missing query parameter 'time'")
self.assertBadRequestResponse(response, "Missing " "query parameter 'time'")

def test_fetch_get_statistics_missing_time_without_time_dimension_dataset(self):
response = self.fetch(
"/statistics/cog_local/band-1?lat=-105.591&lon=35.751&type=Point",
"/statistics/cog_local/band-1?lat=-105.591&" "lon=35.751&type=Point",
method="GET",
)
self.assertResponseOK(response)

def test_fetch_get_statistics_with_time_without_time_dimension_dataset(self):
response = self.fetch(
"/statistics/cog_local/band-1?lat=-105.591&lon=35.751&type=Point&time=2017-01-16+10:09:21",
"/statistics/cog_local/band-1?lat=-105.591&lon=35.751&"
"type=Point&time=2017-01-16+10:09:21",
method="GET",
body='{"type": "Point", "coordinates": [-105.591, 35.751]}',
)
self.assertBadRequestResponse(
response,
"Query parameter 'time' must not be given since dataset does not contain a 'time' dimension",
"Query parameter 'time' must not be given since "
"dataset does not contain a 'time' dimension",
)

def test_fetch_get_statistics_invalid_geometry(self):
response = self.fetch(
"/statistics/demo/conc_chl?time=2017-01-16+10:09:21&lon=1.768&lat=51.465",
"/statistics/demo/conc_chl?time=2017-01-16+10:09:21&"
"lon=1.768&lat=51.465",
method="GET",
)
self.assertResponseOK(response)
4 changes: 2 additions & 2 deletions xcube/webapi/statistics/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _compute_statistics(
time = np.array(time_label, dtype=dataset.time.dtype)
dataset = dataset.sel(time=time, method="nearest")
except (TypeError, ValueError) as e:
raise ApiError.BadRequest("Invalid query parameter 'time'") from e
raise ApiError.BadRequest("Invalid query parameter " "'time'") from e
else:
raise ApiError.BadRequest("Missing query parameter 'time'")
elif time_label is not None:
Expand All @@ -72,7 +72,7 @@ def _compute_statistics(
try:
geometry = shapely.geometry.shape(geometry)
except (TypeError, ValueError, AttributeError) as e:
raise ApiError.BadRequest("Invalid GeoJSON geometry encountered") from e
raise ApiError.BadRequest("Invalid GeoJSON geometry " "encountered") from e

nan_result = NAN_RESULT_COMPACT if compact_mode else NAN_RESULT

Expand Down

0 comments on commit 9b3f312

Please sign in to comment.