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

Make tests framework agnostic #1634

Merged
merged 9 commits into from
Feb 17, 2023
Merged

Conversation

RobbeSneyders
Copy link
Member

Currently, our tests only run against the FlaskApp. This PR parametrizes the relevant tests to run against both the AsyncApp and FlaskApp.

Unfortunately, the test clients provided by Flask and Starlette are not entirely aligned. This PR addresses this by refactoring the tests so they are framework agnostic.

This increased the number of tests from 483 to 709, of which 66 still fail due to issues with the AsyncApp. I will submit separate PRs targeting this branch to fix those.

@RobbeSneyders RobbeSneyders added this to the Connexion 3.0 milestone Feb 13, 2023
@RobbeSneyders
Copy link
Member Author

Unfortunately, the test clients provided by Flask and Starlette are not entirely aligned. This PR addresses this by refactoring the tests so they are framework agnostic.

I added a new commit which uses the Starlette TestClient for the FlaskApp as well. Since both apps are wrapped by ASGI middleware, this works, and we no longer need to write our tests to match both test client interfaces.

62 tests still failing.

RobbeSneyders and others added 7 commits February 16, 2023 09:16
This PR defines a request interface and aligns the `ASGIRequest` with
the `WSGIRequest` class. This brings down the test errors from 62 to 25.
This PR fixes 'outside of Flask context' errors in our test suite and
contains the following changes:

- `Connexion.request` is now a Connexion `ASGIRequest` instead of a
Flask `request`
- All other tests with a Flask dependency have been updated or split

Failing tests are down to 11.
This PR adds all the needed error handling for the AsyncApp.

Only 5 errors remaining.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4192692263

  • 143 of 156 (91.67%) changed or added relevant lines in 13 files are covered.
  • 3 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+2.04%) to 92.151%

Changes Missing Coverage Covered Lines Changed/Added Lines %
connexion/apps/asynchronous.py 0 1 0.0%
connexion/middleware/main.py 1 4 25.0%
connexion/lifecycle.py 106 115 92.17%
Files with Coverage Reduction New Missed Lines %
connexion/frameworks/flask.py 1 93.1%
connexion/lifecycle.py 1 87.34%
connexion/utils.py 1 87.17%
Totals Coverage Status
Change from base Build 4158318028: 2.04%
Covered Lines: 3252
Relevant Lines: 3529

💛 - Coveralls

@RobbeSneyders RobbeSneyders marked this pull request as ready for review February 16, 2023 10:26
@RobbeSneyders RobbeSneyders merged commit 04dcfe1 into main Feb 17, 2023
@RobbeSneyders RobbeSneyders deleted the feature/framework-agnostic-tests branch February 17, 2023 07:22
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

Successfully merging this pull request may close these issues.

3 participants