Skip to content

Commit 63fae9b

Browse files
committed
fix process multi ID/revision resolutions
1 parent 4e56e96 commit 63fae9b

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

tests/functional/test_wps_app.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def test_describe_process_single_revision(self, process_revision):
307307
([(0, "1.3.2"), (1, "1.3.2"), (0, "1.3.4"), (1, "2.0.0")], ),
308308
# ensure optional tag returns both variants as pseudo-duplicates when the corresponding revision is also given
309309
# ("" == "2.0.0"), this is not the same as 'test_describe_process_multi_revision_duplicates' use case
310-
([(0, "1.2.5"), (0, ""), (0, "2.0.0"), (0, ""), (1, "2.0.0")], ),
310+
([(0, "1.2.5"), (0, ""), (0, "2.0.0"), (1, ""), (1, "2.0.0")], ),
311311
])
312312
def test_describe_process_multi_revision_filter(self, process_revisions):
313313
headers = {"Accept": ContentType.APP_XML}
@@ -316,8 +316,8 @@ def test_describe_process_multi_revision_filter(self, process_revisions):
316316
for idx, rev in process_revisions
317317
]
318318
proc_vers = [
319-
rev if rev else self.process_revisions[0][-1]
320-
for rev in process_revisions
319+
rev if rev else self.process_revisions[idx][-1]
320+
for idx, rev in process_revisions
321321
]
322322
params = {
323323
"service": "WPS",
@@ -333,15 +333,16 @@ def test_describe_process_multi_revision_filter(self, process_revisions):
333333
resp.mustcontain(f"ProcessDescription wps:processVersion=\"{proc_ver}\"") # reported regardless of ID:rev
334334
resp.mustcontain(f"<ows:Identifier>{proc_id}</ows:Identifier>") # ID as requested to match search criteria
335335

336-
unrequested_versions = set(self.process_revisions[0]) - set(proc_vers)
337-
for proc_ver in unrequested_versions:
338-
assert f"ProcessDescription wps:processVersion=\"{proc_ver}\"" not in resp.text, "filter did not work"
339-
340336
# number of identifiers must match the requested IDs/revisions that exist,
341337
# even if they represent the same process after optional-latest revision resolution
342338
# to ensure that PyWPS can resolve them against the specified query string ID values
343339
# (PyWPS does not have special 'revision' logic, it considers them distinct processes without relationships)
344-
assert resp.text.count("<ows:Identifier>") == len(process_revisions)
340+
assert sum(
341+
# need to include process ID in check to disambiguate from I/O ID
342+
# however, stop at the 'ID' only (no revision / end XML block) to count all revisions together
343+
resp.text.count(f"<ows:Identifier>{p_id}")
344+
for p_id in self.process_ids
345+
) == len(process_revisions)
345346

346347
def test_describe_process_multi_revision_duplicates(self):
347348
headers = {"Accept": ContentType.APP_XML}

weaver/store/mongodb.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -585,27 +585,22 @@ def list_processes(self,
585585
f"condition_{idx}": [{"$match": {"identifier": proc_id}}]
586586
for idx, proc_id in enumerate(process_latest)
587587
}
588+
process_variants.update({
589+
f"condition_{idx}": [{"$match": {"identifier": proc_id_rev}}]
590+
for idx, proc_id_rev in enumerate(process_revisions, start=len(process_variants))
591+
})
588592
process_variants.update({
589593
f"condition_{idx}": [
594+
{"$match": {"identifier": proc_id, "version": proc_rev}},
595+
# After resolutions, align any 'latest' process that indicates the explicit revision.
596+
# The only case that must be patched is when the version is explicitly indicated in query,
597+
# although not explicit set in the DB document since it corresponds to the latest revision.
590598
{"$set": {"identifier": {"$cond": {
591-
"if": {
592-
# the only case that must be patched is when the version is explicitly indicated in query,
593-
# although not explicit set in the DB document since it corresponds to the latest revision
594-
"$and": [
595-
{"$regexMatch": {"input": "$identifier", "regex": r"^.*(?!:[0-9]+[^:]*)$"}},
596-
{"$not": {"$in": ["$identifier", list(process_ids)]}}
597-
]
598-
},
599+
"if": {"$regexMatch": {"input": "$identifier", "regex": r"^.*(?!:[0-9]+[^:]*)$"}},
599600
"then": {"$concat": ["$identifier", ":", "$version"]},
600601
"else": "$identifier",
601602
}}}},
602-
# then, search by 'ID:revision' whether it was the latest or an actual older revision
603-
{"$match": {"identifier": proc_id_rev}}
604603
]
605-
for idx, proc_id_rev in enumerate(process_revisions, start=len(process_variants))
606-
})
607-
process_variants.update({
608-
f"condition_{idx}": [{"$match": {"identifier": proc_id, "version": proc_rev}}]
609604
for idx, (proc_id, proc_rev) in enumerate(process_id_version, start=len(process_variants))
610605
})
611606
resolve_filter = [

0 commit comments

Comments
 (0)