Skip to content

Commit bcad2e4

Browse files
committed
tests - drop fastapi_versioning
it's broken and seemingly unmaintained c.f. DeanWay/fastapi-versioning#78 referenced PR did not work here https://github.com/mat81black/fastapi-router-versioning does not have an easy migration path removed alltogether
1 parent 2d138e2 commit bcad2e4

8 files changed

Lines changed: 650 additions & 686 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ dev = [
129129
"pytest-cov",
130130
"pytest-mock",
131131
"fastapi",
132-
"fastapi-versioning",
133132
"uvloop",
134133
"flask",
135134
"flask_wtf",

requirements.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# This file was autogenerated by uv via the following command:
22
# uv export --no-dev --no-hashes --no-editable -o requirements.txt
33
.
4-
annotated-types==0.7.0
4+
annotated-types==0.8.0
55
# via pydantic
6-
anyio==4.13.0
6+
anyio==4.14.2
77
# via httpx2
8-
certifi==2026.4.22
9-
# via
10-
# httpcore2
11-
# httpx2
128
dnspython==2.8.0
139
# via email-validator
1410
email-validator==2.3.0
@@ -17,44 +13,49 @@ exceptiongroup==1.3.1 ; python_full_version < '3.11'
1713
# via anyio
1814
h11==0.16.0
1915
# via httpcore2
20-
httpcore2==2.2.0
16+
httpcore2==2.9.0
2117
# via httpx2
22-
httpx2==2.2.0
18+
httpx2==2.9.0
2319
# via aiopenapi3
24-
idna==3.15
20+
idna==3.18
2521
# via
2622
# anyio
2723
# email-validator
2824
# httpx2
2925
# yarl
30-
ijson==3.5.0
26+
ijson==3.5.1
3127
# via aiopenapi3
3228
jmespath==1.1.0
3329
# via aiopenapi3
3430
jsonseq==1.0.0
3531
# via aiopenapi3
36-
more-itertools==11.0.2
32+
more-itertools==11.1.0
3733
# via aiopenapi3
3834
multidict==6.7.1
3935
# via yarl
4036
propcache==0.5.2
4137
# via yarl
42-
pydantic==2.13.4
38+
pydantic==2.14.0a1
4339
# via aiopenapi3
44-
pydantic-core==2.46.4
40+
pydantic-core==2.47.0
4541
# via pydantic
4642
pyyaml==6.0.3
4743
# via aiopenapi3
48-
typing-extensions==4.15.0
44+
truststore==0.10.4
45+
# via
46+
# httpcore2
47+
# httpx2
48+
typing-extensions==4.16.0
4949
# via
5050
# aiopenapi3
5151
# anyio
5252
# exceptiongroup
53+
# httpx2
5354
# multidict
5455
# pydantic
5556
# pydantic-core
5657
# typing-inspection
5758
typing-inspection==0.4.2
5859
# via pydantic
59-
yarl==1.23.0
60+
yarl==1.24.5
6061
# via aiopenapi3

tests/api/main.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/api/v1/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
from .schema import Pets, Pet, PetCreate, Error
88

9-
10-
from fastapi_versioning import versioned_api_route
11-
12-
router = APIRouter(route_class=versioned_api_route(1))
9+
router = APIRouter(prefix="/v1")
1310

1411

1512
ZOO = dict()

tests/api/v2/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88

99
from . import schema
1010

11-
from fastapi_versioning import versioned_api_route
12-
13-
14-
router = APIRouter(route_class=versioned_api_route(2))
11+
router = APIRouter(prefix="/v2")
1512

1613
ZOO = dict()
1714

tests/apiv1_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
from hypercorn.asyncio import serve
88
from hypercorn.config import Config
99

10+
from fastapi import FastAPI
11+
1012
import aiopenapi3
1113

1214
# pytest.skip(allow_module_level=True)
1315

14-
from api.main import app
16+
from api.v1.main import router
17+
18+
app = FastAPI(
19+
version="1.0.0", title="Dorthu's Petstore", servers=[{"url": "/", "description": "Default, relative server"}]
20+
)
21+
app.include_router(router)
1522

1623

1724
@pytest.fixture(scope="session")
@@ -35,7 +42,7 @@ async def server(config):
3542

3643
@pytest_asyncio.fixture(loop_scope="session")
3744
async def client(server):
38-
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, f"http://{server.bind[0]}/v1/openapi.json")
45+
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, f"http://{server.bind[0]}/openapi.json")
3946
return api
4047

4148

tests/apiv2_test.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@
1818
from aiopenapi3 import OpenAPI
1919
from aiopenapi3.v31.schemas import Schema
2020

21-
from api.main import app
2221
from api.v2.schema import Dog as _Dog
2322

2423
# pytest.skip(allow_module_level=True)
2524

25+
from fastapi import FastAPI
2626
from fastapi.responses import PlainTextResponse
2727

2828

29+
from api.v2.main import router
30+
31+
app = FastAPI(
32+
version="1.0.0", title="Dorthu's Petstore", servers=[{"url": "/", "description": "Default, relative server"}]
33+
)
34+
app.include_router(router)
35+
36+
2937
@app.exception_handler(Exception)
3038
async def validation_exception_handler(request, exc):
3139
return PlainTextResponse(str(exc), status_code=400)
@@ -50,25 +58,20 @@ async def server(config):
5058
await task
5159

5260

53-
@pytest.fixture(scope="session", params=[2])
54-
def version(request):
55-
return f"v{request.param}"
56-
57-
5861
from aiopenapi3.debug import DescriptionDocumentDumper
5962

6063

6164
@pytest_asyncio.fixture(loop_scope="session")
62-
async def client(server, version):
63-
url = f"http://{server.bind[0]}/{version}/openapi.json"
65+
async def client(server):
66+
url = f"http://{server.bind[0]}/openapi.json"
6467

6568
api = await aiopenapi3.OpenAPI.load_async(url, plugins=[DescriptionDocumentDumper("/tmp/schema.yaml")])
6669
return api
6770

6871

6972
@pytest.mark.asyncio(loop_scope="session")
7073
@pytest.mark.xfail()
71-
def test_Pet():
74+
async def test_Pet():
7275

7376
data = _Dog.model_json_schema()
7477
# print(json.dumps(data, indent=True))
@@ -80,15 +83,15 @@ def test_Pet():
8083

8184

8285
@pytest.mark.asyncio(loop_scope="session")
83-
async def test_sync(server, version):
84-
url = f"http://{server.bind[0]}/{version}/openapi.json"
86+
async def test_sync(server):
87+
url = f"http://{server.bind[0]}/openapi.json"
8588
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, url)
8689
return api
8790

8891

8992
@pytest.mark.asyncio(loop_scope="session")
90-
async def test_description_document(server, version):
91-
url = f"http://{server.bind[0]}/{version}/openapi.json"
93+
async def test_description_document(server):
94+
url = f"http://{server.bind[0]}/openapi.json"
9295
api = await aiopenapi3.OpenAPI.load_async(url)
9396
return api
9497

0 commit comments

Comments
 (0)