Skip to content

Commit

Permalink
Switch test_collections to use include based on regex. Avoids double-…
Browse files Browse the repository at this point in the history
…testing /collections.
  • Loading branch information
Lars Falk-Petersen committed Sep 26, 2024
1 parent 3fd748c commit f8ace4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions img/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Icon

from <https://www.freepik.com/icon/tree_14856504#fromView=search&page=1&position=4&uuid=7d4a45b5-b082-487e-9fee-48dfd33a5a68>
17 changes: 7 additions & 10 deletions sedr/schemat.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def set_up_schemathesis(args):

schema = set_up_schemathesis(util.args)

# Require /collections to exist, in accordance with Requirement A.2.2 A.9
# <https://docs.ogc.org/is/19-086r6/19-086r6.html#_26b5ceeb-1127-4dc1-b88e-89a32d73ade9>
_ = schema["/collections"]["GET"]


@schema.parametrize() # parametrize => Create tests for all operations in schema
@settings(max_examples=util.args.iterations, deadline=None)
Expand Down Expand Up @@ -136,15 +132,16 @@ def test_conformance(case):
util.logger.debug("Conformance %s tested OK", response.url)


@schema.parametrize()
@schema.include(path_regex="^" + util.args.base_path + "collections$").parametrize()
@settings(max_examples=util.args.iterations, deadline=None)
def test_collections(case):
"""The default testing in function test_api() will fuzz the collections. This function will test that collections contain EDR spesifics."""
"""The default testing in function test_api() will fuzz the collections. This function will test that collections contain EDR spesifics.
It will also require /collections to exist, in accordance with Requirement A.2.2 A.9
<https://docs.ogc.org/is/19-086r6/19-086r6.html#_26b5ceeb-1127-4dc1-b88e-89a32d73ade9>
"""
global collection_ids, extents

if not case.path.endswith("/collections"):
return

response = case.call()
spec_ref = "https://docs.ogc.org/is/19-086r6/19-086r6.html#_ed0b4d0d-f90a-4a7d-a123-17a1d7849b2d"

Expand Down Expand Up @@ -183,7 +180,7 @@ def test_collections(case):
f"Unable to find extent for collection ID {collection['id']}. Found [{', '.join(collection.keys())}]. See {spec_ref} for more info."
) from err

util.logger.debug("Collections %s tested OK", response.url)
# util.logger.debug("Collections %s tested OK", response.url)


# @schema.parametrize()
Expand Down
1 change: 1 addition & 0 deletions sedr/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class TestUtil(unittest.TestCase):

def test_parse_landing_json(self):
"""Test parsing a generic landing page in json."""
with open("../testdata/landingpage.json", "r", encoding="utf-8") as f:
landingpage_json = json.loads(f.read())
landing, _ = util.parse_landing_json(landingpage_json)
Expand Down

0 comments on commit f8ace4f

Please sign in to comment.