Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
havardf opened this issue Oct 8, 2024 · 3 comments
Open

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

havardf opened this issue Oct 8, 2024 · 3 comments

Comments

@havardf
Copy link
Collaborator

havardf commented Oct 8, 2024

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
Copy link
Collaborator

ways commented Oct 11, 2024

======================================== 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 pushed a commit that referenced this issue Oct 11, 2024
@ways
Copy link
Collaborator

ways commented Oct 11, 2024

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

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

@ways
Copy link
Collaborator

ways commented Nov 20, 2024

Testing for this requires something like #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants