Skip to content

Commit

Permalink
Return empty list if no coverages are found instead of error
Browse files Browse the repository at this point in the history
There shouldn't be an error code because the request is valid and the
empty list is the correct response
  • Loading branch information
totycro committed May 25, 2023
1 parent c8d2ff1 commit bc261e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
31 changes: 31 additions & 0 deletions autotest/autotest_services/tests/wps/test_v20_cloud_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,37 @@ def getRequest(self):
return (params, "xml")


class WPS20ExecuteCloudCoverageEmptyResponse(
ContentTypeCheckMixIn, testbase.JSONTestCase
):
# Don't add cloud coverage fixture to provoke empty response
fixtures = testbase.JSONTestCase.fixtures + []

expectedContentType = "application/json; charset=utf-8"

def getRequest(self):
params = """<wps:Execute
version="2.0.0"
service="WPS"
response="raw"
mode="sync"
xmlns:wps="http://www.opengis.net/wps/2.0"
xmlns:ows="http://www.opengis.net/ows/2.0" >
<ows:Identifier>CloudCoverage</ows:Identifier>
<wps:Input id="begin_time"><wps:Data>2020-01-01</wps:Data></wps:Input>
<wps:Input id="end_time"><wps:Data>2020-05-31</wps:Data></wps:Input>
<wps:Input id="geometry">
<wps:Data>
<wps:ComplexData mimeType="text/plain">POLYGON((69.1714578 80.1407449,69.17148193988112 80.14073878013805,69.17149910356903 80.1407419147403,69.1714578 80.1407449))</wps:ComplexData>
</wps:Data>
</wps:Input>
<wps:Output id="result" >
</wps:Output>
</wps:Execute>
"""
return (params, "xml")


class WPS20ExecuteCloudCoverageOnCLM(ContentTypeCheckMixIn, testbase.JSONTestCase):
fixtures = testbase.JSONTestCase.fixtures + ["clm_cloud_coverages.json"]

Expand Down
5 changes: 3 additions & 2 deletions eoxserver/services/ows/wps/processes/get_cloud_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from eoxserver.contrib import gdal
from eoxserver.resources.coverages import models
from eoxserver.backends.access import gdal_open
from eoxserver.services.ows.wps.exceptions import InvalidInputValueError
from eoxserver.services.ows.wps.parameters import (
LiteralData,
ComplexData,
Expand Down Expand Up @@ -135,7 +134,9 @@ def execute(
no_data_value = None

else:
raise InvalidInputValueError("No coverage data found")
calculation_fun = None
coverages = []
no_data_value = None

with concurrent.futures.ThreadPoolExecutor(max_workers=5) as e:
cloud_coverage_ratios = e.map(
Expand Down

0 comments on commit bc261e3

Please sign in to comment.