Add example of using the Starlette test client with tox
The example Connexion app processes JSON requests and responses as specified with OpenAPI v2 (aka Swagger) or OpenAPI v3 file format.
JSON responses are validated against the spec.
An error handler catches exceptions raised while processing a request.
Tests are run by tox which also reports code coverage.
Fixes: #1988
Thanks for approving a run of the test pipeline on this PR. I botched the import order in my initial attempts, I'm learning to run isort on everything first. I'm struggling to figure out the exact version of isort to use, or the right configuration, because the import ordering set by my local isort was rejected by the tox pre-commit step :/
coverage: 94.297%. remained the same when pulling c4aab022e2598cc000a0f9a6082a96498f194219 on chrisinmtown:example-testclient into df9960b9f8d5d438a6774309b866cc2153de2b18 on spec-first:main.
Thanks for approving a run of the test pipeline on this PR. I botched the import order in my initial attempts, I'm learning to run
isorton everything first. I'm struggling to figure out the exact version ofisortto use, or the right configuration, because the import ordering set by my localisortwas rejected by the toxpre-commitstep :/
No worries, I have been using ruff on my other projects as it combines a lot of these into a single tool, that's more easy to use imo. Is it still unclear?
Greetings @Ruwann and @RobbeSneyders I think I addressed all your comments on this PR, please advise if you would like this example in the V3 codebase, thanks.
This PR addresses issue #1988 with an example instead of a revised document. Please comment.
Looks like two my PRs are fighting with each other :( This PR adds a "tests" directory, it's the only example with that. Unfortunately the very recently merged change to tox.ini (that allows choice of scope) now seems to cause pytest to pull in the newly added "tests/conftest.py" file from this new example instead of the top-level "test/conftest.py" file, leading to immediate failures. I speculate it's because of the entry "testspaths=tests" in tox.ini. Trying to figure out a workaround.
I submitted a PR to restore the tests argument to the poetry invocation of pytest, that limits the directory scope, and then the files introduced by this PR are not picked up and used during a normal test run of Connexion, see #2092