File: test_path_parameters.py

package info (click to toggle)
litestar 2.19.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,500 kB
  • sloc: python: 70,169; makefile: 254; javascript: 105; sh: 60
file content (29 lines) | stat: -rw-r--r-- 1,011 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
23
24
25
26
27
28
29
from docs.examples.parameters.path_parameters_1 import app
from docs.examples.parameters.path_parameters_2 import app as app_2
from docs.examples.parameters.path_parameters_3 import app as app_3

from litestar.testing import TestClient


def test_path_parameters_1() -> None:
    with TestClient(app=app) as client:
        response = client.get("/user/1")
        assert response.status_code == 200
        assert response.json() == {"id": 1, "name": "John Doe"}


def test_path_parameters_2() -> None:
    with TestClient(app=app_2) as client:
        response = client.get("/orders/1667924386")
        assert response.status_code == 200
        assert response.json() == [
            {"id": 1, "customer_id": 2},
            {"id": 2, "customer_id": 2},
        ]


def test_path_parameters_3() -> None:
    with TestClient(app=app_3) as client:
        response = client.get("/versions/1")
        assert response.status_code == 200
        assert response.json() == {"id": 1, "specs": {"some": "value"}}