File: test_list_with_default_value.py

package info (click to toggle)
flask-openapi3 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,976 kB
  • sloc: python: 4,754; sh: 17; makefile: 15; javascript: 5
file content (45 lines) | stat: -rw-r--r-- 751 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2024/9/29 10:36
import pytest
from pydantic import BaseModel

from flask_openapi3 import OpenAPI

app = OpenAPI(__name__)
app.config["TESTING"] = True


@pytest.fixture
def client():
    client = app.test_client()

    return client


class BookQuery(BaseModel):
    age: list[int] = [1, 2]


class BookForm(BaseModel):
    age: list[float] = [3, 4]


@app.get("/query")
def api_query(query: BookQuery):
    assert query.age == [1, 2]
    return {"code": 0, "message": "ok"}


@app.post("/form")
def api_form(form: BookForm):
    assert form.age == [3, 4]
    return {"code": 0, "message": "ok"}


def test_query(client):
    client.get("/query")


def test_form(client):
    client.post("/form")