1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
# This is no longer the case in pydantic 2
# https://github.com/pydantic/pydantic/issues/5991
# from datetime import date
# from typing import Union
# from ninja import Router
# from ninja.testing import TestClient
# router = Router()
# @router.get("/test")
# def view(request, value: Union[date, str]):
# return [value, type(value).__name__]
# client = TestClient(router)
# def test_union():
# assert client.get("/test?value=today").json() == ["today", "str"]
# assert client.get("/test?value=2020-01-15").json() == ["2020-01-15", "date"]
|