metno / sedr

An experiment to validate OGC EDR APIs using schemathesis, and give good feedback to developers.
GNU General Public License v2.0
0 stars 0 forks source link

schema.include filters fail when base_path is not / #9

Open havardf opened 1 week ago

havardf commented 1 week ago

Today filters like @schema.include(path_regex="^" + util.args.base_path + "conformance").parametrize() could fail to work when the OpenAPI document for the service includes a server block with url like https://edr.example.com/foo.

The filters will only work when the base_path is /.

The best fix is not entirely obvious since these hardcoded include paths need to match correctly with how the schemathesis builds up the absolute paths from paths + server urls in the openapi document.

But the above example will work if the filter was changed to: @schema.include(path_regex="^" + util.args.base_path + "/conformance").parametrize()

ways commented 1 week ago
======================================== ERRORS =========================================
___________________________ ERROR collecting sedr/schemat.py ____________________________
venv/lib/python3.12/site-packages/schemathesis/extra/pytest_plugin.py:222: in collect
    fail_on_no_matches(self.nodeid)
venv/lib/python3.12/site-packages/schemathesis/utils.py:43: in fail_on_no_matches
    pytest.fail(f"Test function {node_id} does not match any API operations and therefore has no effect")
E   Failed: Test function sedr/schemat.py::test_edr_conformance does not match any API operations and therefore has no effect
================================ short test summary info ================================
ERROR sedr/schemat.py::test_edr_conformance - Failed: Test function sedr/schemat.py::test_edr_conformance does not match any API o...
!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!
=================================== 1 error in 2.10s ====================================

Tried your fix. Doesn't seem to be as simple as that. Will attempt to join the url properly to not have repeat slashes.

ways commented 1 week ago

Check if tag v0.7.6-1 fixes this problem, please.

docker run -it --rm ghcr.io/metno/sedr:0.7.6-1 --url ...