Skip to content

Commit

Permalink
test WPS endpoint to allow execute with empty string input
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Sep 5, 2023
1 parent 77271b6 commit 64d1499
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/functional/test_wps_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
setup_config_with_celery,
setup_config_with_mongodb,
setup_config_with_pywps,
setup_mongodb_jobstore,
setup_mongodb_processstore
)
from weaver import xml_util
Expand All @@ -45,6 +46,7 @@ def setUp(self):
config = setup_config_with_pywps(config)
config = setup_config_with_celery(config)
self.process_store = setup_mongodb_processstore(config)
self.job_store = setup_mongodb_jobstore(config)
self.app = get_test_weaver_app(config=config, settings=settings)

# add processes by database Process type
Expand Down Expand Up @@ -146,6 +148,24 @@ def test_execute_allowed_demo(self):
resp.mustcontain("<wps:ProcessAccepted")
resp.mustcontain(f"PyWPS Process {HelloWPS.identifier}")

def test_execute_allowed_empty_string(self):
template = "service=wps&request=execute&version=1.0.0&identifier={}&datainputs=name="
params = template.format(HelloWPS.identifier)
url = self.make_url(params)
with contextlib.ExitStack() as stack_exec:
for mock_exec in mocked_execute_celery():
stack_exec.enter_context(mock_exec)
resp = self.app.get(url)
assert resp.status_code == 200 # FIXME: replace by 202 Accepted (?) https://github.com/crim-ca/weaver/issues/14
assert resp.content_type in ContentType.ANY_XML
resp.mustcontain("<wps:ExecuteResponse")
resp.mustcontain("<wps:ProcessAccepted")
resp.mustcontain(f"PyWPS Process {HelloWPS.identifier}")
loc = resp.xml.get("statusLocation")
job_id = loc.rsplit("/", 1)[-1].split(".", 1)[0]
job = self.job_store.fetch_by_id(job_id)
assert job.inputs[0]["data"] == ""

def test_execute_deployed_with_visibility_allowed(self):
headers = {"Accept": ContentType.APP_XML}
params_template = "service=wps&request=execute&version=1.0.0&identifier={}&datainputs=test_input=test"
Expand Down
2 changes: 1 addition & 1 deletion weaver/store/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ def delete_job(self, job_id):
result = self.collection.delete_one({"id": job_id})
return result.deleted_count == 1

def fetch_by_id(self, job_id):
def c(self, job_id):
# type: (AnyUUID) -> Job
"""
Gets job for given ``job_id`` from `MongoDB` storage.
Expand Down

0 comments on commit 64d1499

Please sign in to comment.