File: test_server.py

package info (click to toggle)
flask-openapi3 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,224 kB
  • sloc: python: 4,807; makefile: 14; javascript: 5
file content (31 lines) | stat: -rw-r--r-- 932 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
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2024/11/10 12:17
from pydantic import ValidationError

from flask_openapi3 import Server, ServerVariable


def test_server_variable():
    Server(url="http://127.0.0.1:5000", variables=None)
    try:
        variables = {"one": ServerVariable(default="one", enum=[])}
        Server(url="http://127.0.0.1:5000", variables=variables)
        error = 0
    except ValidationError:
        error = 1
    assert error == 1
    try:
        variables = {"one": ServerVariable(default="one")}
        Server(url="http://127.0.0.1:5000", variables=variables)
        error = 0
    except ValidationError:
        error = 1
    assert error == 0
    try:
        variables = {"one": ServerVariable(default="one", enum=["one", "two"])}
        Server(url="http://127.0.0.1:5000", variables=variables)
        error = 0
    except ValidationError:
        error = 1
    assert error == 0