lqs
d20566fe07
Some checks failed
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
78 lines
1.7 KiB
Python
78 lines
1.7 KiB
Python
from typing import Dict, List, Tuple
|
|
|
|
import pytest
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
|
|
def test_invalid_sequence():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: List[Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_tuple():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: Tuple[Item, Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_dict():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: Dict[str, Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_list():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: list):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_tuple():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: tuple):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_set():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: set):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_dict():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: dict):
|
|
pass # pragma: no cover
|