File: test_union.py

package info (click to toggle)
django-ninja 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,280 kB
  • sloc: python: 16,041; javascript: 1,689; makefile: 40; sh: 25
file content (22 lines) | stat: -rw-r--r-- 560 bytes parent folder | download
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"]