3 changed files with 30 additions and 33 deletions
@ -1,34 +1,32 @@ |
|||||
from __future__ import annotations |
from __future__ import annotations |
||||
|
|
||||
import sys |
from typing import Optional |
||||
|
|
||||
from ..utils import needs_py310 |
from fastapi import FastAPI |
||||
|
from fastapi.testclient import TestClient |
||||
|
from pydantic import BaseModel |
||||
|
|
||||
if sys.version_info > (3, 10): |
from ..utils import needs_py310 |
||||
from typing import Optional |
from .login_tool import login_required |
||||
|
|
||||
from fastapi import FastAPI |
app = FastAPI() |
||||
from fastapi.testclient import TestClient |
client = TestClient(app) |
||||
from pydantic import BaseModel |
|
||||
|
|
||||
from .loging_tool import login_required |
|
||||
|
|
||||
app = FastAPI() |
class Item(BaseModel): |
||||
client = TestClient(app) |
name: str |
||||
|
description: Optional[str] = None |
||||
|
price: float |
||||
|
tax: Optional[float] = None |
||||
|
|
||||
class Item(BaseModel): |
|
||||
name: str |
|
||||
description: Optional[str] = None |
|
||||
price: float |
|
||||
tax: Optional[float] = None |
|
||||
|
|
||||
@app.get("/items/") |
@app.get("/items/") |
||||
@login_required |
@login_required |
||||
def get_item(id: int) -> Item: |
def get_item(item_id: int) -> Item: |
||||
return Item(name="name", price=42.42) |
return Item(name="name", price=42.42) |
||||
|
|
||||
|
|
||||
@needs_py310 |
@needs_py310 |
||||
def test_future_6465(): |
def test_future_6465(): |
||||
res = client.get("/items?id=3") |
res = client.get("/items?item_id=3") |
||||
assert res.status_code == 200 |
assert res.status_code == 200 |
||||
|
Loading…
Reference in new issue