forked from loafle/openapi-generator-original
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:
parent
a2c1b02840
commit
1f5b590d5a
6
.github/workflows/samples-python-server.yaml
vendored
6
.github/workflows/samples-python-server.yaml
vendored
@ -3,10 +3,10 @@ name: Python Server
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/server/petstore/python-aiohttp/**
|
||||
- samples/server/petstore/python-aiohttp-srclayout/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/petstore/python-aiohttp/**
|
||||
- samples/server/petstore/python-aiohttp-srclayout/**
|
||||
jobs:
|
||||
build:
|
||||
name: Test Python server
|
||||
@ -16,7 +16,7 @@ jobs:
|
||||
matrix:
|
||||
sample:
|
||||
# servers
|
||||
- samples/server/petstore/python-aiohttp/
|
||||
- samples/server/petstore/python-aiohttp-srclayout/
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
|
@ -17,6 +17,8 @@ from aiohttp import FormData
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
{{#vendorExtensions.x-skip-test}}
|
||||
@pytest.mark.skip("{{reason}}")
|
||||
{{/vendorExtensions.x-skip-test}}
|
||||
|
@ -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
|
||||
@ -10,3 +10,4 @@ aiohttp_jinja2 == 1.5.0
|
||||
{{#featureCORS}}
|
||||
aiohttp_cors >= 0.7.0
|
||||
{{/featureCORS}}
|
||||
Flask < 2.3
|
@ -8,4 +8,4 @@ deps=-r{toxinidir}/requirements.txt
|
||||
{toxinidir}
|
||||
|
||||
commands=
|
||||
{{^useNose}}pytest --cov={{#lambda.forwardslash}}{{{pythonSrcRoot}}}{{/lambda.forwardslash}}{{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}}
|
||||
{{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}}
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -8,4 +8,4 @@ deps=-r{toxinidir}/requirements.txt
|
||||
{toxinidir}
|
||||
|
||||
commands=
|
||||
pytest --cov=src/openapi_server
|
||||
pytest --cov=openapi_server
|
||||
|
Loading…
x
Reference in New Issue
Block a user