connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Add example of using the Starlette test client with tox

Open chrisinmtown opened this issue 11 months ago • 7 comments

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

chrisinmtown avatar Jan 04 '25 12:01 chrisinmtown

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 :/

chrisinmtown avatar Jan 04 '25 13:01 chrisinmtown

Coverage Status

coverage: 94.297%. remained the same when pulling c4aab022e2598cc000a0f9a6082a96498f194219 on chrisinmtown:example-testclient into df9960b9f8d5d438a6774309b866cc2153de2b18 on spec-first:main.

coveralls avatar Jan 04 '25 13:01 coveralls

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 :/

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?

Ruwann avatar Feb 01 '25 15:02 Ruwann

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.

chrisinmtown avatar Jun 22 '25 10:06 chrisinmtown

This PR addresses issue #1988 with an example instead of a revised document. Please comment.

chrisinmtown avatar Jul 24 '25 14:07 chrisinmtown

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.

chrisinmtown avatar Oct 13 '25 12:10 chrisinmtown

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

chrisinmtown avatar Oct 13 '25 12:10 chrisinmtown