Python-server workflow fixes + pytest (#17060)

* Fix referenced path for tests

* Explicit dependencies

Flask 2.3 has breaking changes

* Marks all async tests with pytest.mark.asyncio

Otherwise they are skipped by pytest and coverage is zero

* Fix path for pytest

On suggestion from https://github.com/OpenAPITools/openapi-generator/pull/17060#discussion_r1392666369
This commit is contained in:
Aurélien Joga
2023-11-18 03:10:10 +01:00
committed by GitHub
parent a2c1b02840
commit 1f5b590d5a
10 changed files with 15 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
connexion[aiohttp,swagger-ui] >= 2.6.0; python_version>="3.6"
connexion[aiohttp,swagger-ui] >= 2.6.0, <3; python_version>="3.6"
# 2.3 is the last version that supports python 3.5
connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
@@ -7,3 +7,4 @@ connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle == 0.0.9
aiohttp_jinja2 == 1.5.0
Flask < 2.3

View File

@@ -23,7 +23,7 @@ pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT
tox || exit 1
### static analysis of code
flake8 --show-source petstore_api/
flake8 --show-source ./src
### deactivate virtualenv
if [ $DEACTIVE == true ]; then

View File

@@ -8,6 +8,7 @@ from aiohttp import FormData
from openapi_server.models.api_response import ApiResponse
from openapi_server.models.pet import Pet
pytestmark = pytest.mark.asyncio
@pytest.mark.skip("Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760")
async def test_add_pet(client):

View File

@@ -6,6 +6,7 @@ from aiohttp import web
from openapi_server.models.order import Order
pytestmark = pytest.mark.asyncio
async def test_delete_order(client):
"""Test case for delete_order

View File

@@ -6,6 +6,7 @@ from aiohttp import web
from openapi_server.models.user import User
pytestmark = pytest.mark.asyncio
@pytest.mark.skip("*/* not supported by Connexion. Use application/json instead. See https://github.com/zalando/connexion/pull/760")
async def test_create_user(client):

View File

@@ -8,4 +8,4 @@ deps=-r{toxinidir}/requirements.txt
{toxinidir}
commands=
pytest --cov=src/openapi_server
pytest --cov=openapi_server