同步操作将从 Gitee 极速下载/FastAPI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from dirty_equals import IsDictfrom fastapi.testclient import TestClientfrom fastapi.utils import match_pydantic_error_urlfrom .main import appclient = TestClient(app)def test_text_get():response = client.get("/text")assert response.status_code == 200, response.textassert response.json() == "Hello World"def test_nonexistent():response = client.get("/nonexistent")assert response.status_code == 404, response.textassert response.json() == {"detail": "Not Found"}def test_path_foobar():response = client.get("/path/foobar")assert response.status_code == 200assert response.json() == "foobar"def test_path_str_foobar():response = client.get("/path/str/foobar")assert response.status_code == 200assert response.json() == "foobar"def test_path_str_42():response = client.get("/path/str/42")assert response.status_code == 200assert response.json() == "42"def test_path_str_True():response = client.get("/path/str/True")assert response.status_code == 200assert response.json() == "True"def test_path_int_foobar():response = client.get("/path/int/foobar")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "foobar","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_int_True():response = client.get("/path/int/True")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "True","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_int_42():response = client.get("/path/int/42")assert response.status_code == 200assert response.json() == 42def test_path_int_42_5():response = client.get("/path/int/42.5")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "42.5","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_float_foobar():response = client.get("/path/float/foobar")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "float_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid number, unable to parse string as a number","input": "foobar","url": match_pydantic_error_url("float_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid float","type": "type_error.float",}]})def test_path_float_True():response = client.get("/path/float/True")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "float_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid number, unable to parse string as a number","input": "True","url": match_pydantic_error_url("float_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid float","type": "type_error.float",}]})def test_path_float_42():response = client.get("/path/float/42")assert response.status_code == 200assert response.json() == 42def test_path_float_42_5():response = client.get("/path/float/42.5")assert response.status_code == 200assert response.json() == 42.5def test_path_bool_foobar():response = client.get("/path/bool/foobar")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "bool_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid boolean, unable to interpret input","input": "foobar","url": match_pydantic_error_url("bool_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value could not be parsed to a boolean","type": "type_error.bool",}]})def test_path_bool_True():response = client.get("/path/bool/True")assert response.status_code == 200assert response.json() is Truedef test_path_bool_42():response = client.get("/path/bool/42")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "bool_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid boolean, unable to interpret input","input": "42","url": match_pydantic_error_url("bool_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value could not be parsed to a boolean","type": "type_error.bool",}]})def test_path_bool_42_5():response = client.get("/path/bool/42.5")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "bool_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid boolean, unable to interpret input","input": "42.5","url": match_pydantic_error_url("bool_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value could not be parsed to a boolean","type": "type_error.bool",}]})def test_path_bool_1():response = client.get("/path/bool/1")assert response.status_code == 200assert response.json() is Truedef test_path_bool_0():response = client.get("/path/bool/0")assert response.status_code == 200assert response.json() is Falsedef test_path_bool_true():response = client.get("/path/bool/true")assert response.status_code == 200assert response.json() is Truedef test_path_bool_False():response = client.get("/path/bool/False")assert response.status_code == 200assert response.json() is Falsedef test_path_bool_false():response = client.get("/path/bool/false")assert response.status_code == 200assert response.json() is Falsedef test_path_param_foo():response = client.get("/path/param/foo")assert response.status_code == 200assert response.json() == "foo"def test_path_param_minlength_foo():response = client.get("/path/param-minlength/foo")assert response.status_code == 200assert response.json() == "foo"def test_path_param_minlength_fo():response = client.get("/path/param-minlength/fo")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "string_too_short","loc": ["path", "item_id"],"msg": "String should have at least 3 characters","input": "fo","ctx": {"min_length": 3},"url": match_pydantic_error_url("string_too_short"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value has at least 3 characters","type": "value_error.any_str.min_length","ctx": {"limit_value": 3},}]})def test_path_param_maxlength_foo():response = client.get("/path/param-maxlength/foo")assert response.status_code == 200assert response.json() == "foo"def test_path_param_maxlength_foobar():response = client.get("/path/param-maxlength/foobar")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "string_too_long","loc": ["path", "item_id"],"msg": "String should have at most 3 characters","input": "foobar","ctx": {"max_length": 3},"url": match_pydantic_error_url("string_too_long"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value has at most 3 characters","type": "value_error.any_str.max_length","ctx": {"limit_value": 3},}]})def test_path_param_min_maxlength_foo():response = client.get("/path/param-min_maxlength/foo")assert response.status_code == 200assert response.json() == "foo"def test_path_param_min_maxlength_foobar():response = client.get("/path/param-min_maxlength/foobar")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "string_too_long","loc": ["path", "item_id"],"msg": "String should have at most 3 characters","input": "foobar","ctx": {"max_length": 3},"url": match_pydantic_error_url("string_too_long"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value has at most 3 characters","type": "value_error.any_str.max_length","ctx": {"limit_value": 3},}]})def test_path_param_min_maxlength_f():response = client.get("/path/param-min_maxlength/f")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "string_too_short","loc": ["path", "item_id"],"msg": "String should have at least 2 characters","input": "f","ctx": {"min_length": 2},"url": match_pydantic_error_url("string_too_short"),}]}) | IsDict({"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value has at least 2 characters","type": "value_error.any_str.min_length","ctx": {"limit_value": 2},}]})def test_path_param_gt_42():response = client.get("/path/param-gt/42")assert response.status_code == 200assert response.json() == 42def test_path_param_gt_2():response = client.get("/path/param-gt/2")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than","loc": ["path", "item_id"],"msg": "Input should be greater than 3","input": "2","ctx": {"gt": 3.0},"url": match_pydantic_error_url("greater_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than 3","type": "value_error.number.not_gt","ctx": {"limit_value": 3},}]})def test_path_param_gt0_0_05():response = client.get("/path/param-gt0/0.05")assert response.status_code == 200assert response.json() == 0.05def test_path_param_gt0_0():response = client.get("/path/param-gt0/0")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than","loc": ["path", "item_id"],"msg": "Input should be greater than 0","input": "0","ctx": {"gt": 0.0},"url": match_pydantic_error_url("greater_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than 0","type": "value_error.number.not_gt","ctx": {"limit_value": 0},}]})def test_path_param_ge_42():response = client.get("/path/param-ge/42")assert response.status_code == 200assert response.json() == 42def test_path_param_ge_3():response = client.get("/path/param-ge/3")assert response.status_code == 200assert response.json() == 3def test_path_param_ge_2():response = client.get("/path/param-ge/2")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than_equal","loc": ["path", "item_id"],"msg": "Input should be greater than or equal to 3","input": "2","ctx": {"ge": 3.0},"url": match_pydantic_error_url("greater_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than or equal to 3","type": "value_error.number.not_ge","ctx": {"limit_value": 3},}]})def test_path_param_lt_42():response = client.get("/path/param-lt/42")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than","loc": ["path", "item_id"],"msg": "Input should be less than 3","input": "42","ctx": {"lt": 3.0},"url": match_pydantic_error_url("less_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than 3","type": "value_error.number.not_lt","ctx": {"limit_value": 3},}]})def test_path_param_lt_2():response = client.get("/path/param-lt/2")assert response.status_code == 200assert response.json() == 2def test_path_param_lt0__1():response = client.get("/path/param-lt0/-1")assert response.status_code == 200assert response.json() == -1def test_path_param_lt0_0():response = client.get("/path/param-lt0/0")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than","loc": ["path", "item_id"],"msg": "Input should be less than 0","input": "0","ctx": {"lt": 0.0},"url": match_pydantic_error_url("less_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than 0","type": "value_error.number.not_lt","ctx": {"limit_value": 0},}]})def test_path_param_le_42():response = client.get("/path/param-le/42")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than_equal","loc": ["path", "item_id"],"msg": "Input should be less than or equal to 3","input": "42","ctx": {"le": 3.0},"url": match_pydantic_error_url("less_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than or equal to 3","type": "value_error.number.not_le","ctx": {"limit_value": 3},}]})def test_path_param_le_3():response = client.get("/path/param-le/3")assert response.status_code == 200assert response.json() == 3def test_path_param_le_2():response = client.get("/path/param-le/2")assert response.status_code == 200assert response.json() == 2def test_path_param_lt_gt_2():response = client.get("/path/param-lt-gt/2")assert response.status_code == 200assert response.json() == 2def test_path_param_lt_gt_4():response = client.get("/path/param-lt-gt/4")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than","loc": ["path", "item_id"],"msg": "Input should be less than 3","input": "4","ctx": {"lt": 3.0},"url": match_pydantic_error_url("less_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than 3","type": "value_error.number.not_lt","ctx": {"limit_value": 3},}]})def test_path_param_lt_gt_0():response = client.get("/path/param-lt-gt/0")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than","loc": ["path", "item_id"],"msg": "Input should be greater than 1","input": "0","ctx": {"gt": 1.0},"url": match_pydantic_error_url("greater_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than 1","type": "value_error.number.not_gt","ctx": {"limit_value": 1},}]})def test_path_param_le_ge_2():response = client.get("/path/param-le-ge/2")assert response.status_code == 200assert response.json() == 2def test_path_param_le_ge_1():response = client.get("/path/param-le-ge/1")assert response.status_code == 200def test_path_param_le_ge_3():response = client.get("/path/param-le-ge/3")assert response.status_code == 200assert response.json() == 3def test_path_param_le_ge_4():response = client.get("/path/param-le-ge/4")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than_equal","loc": ["path", "item_id"],"msg": "Input should be less than or equal to 3","input": "4","ctx": {"le": 3.0},"url": match_pydantic_error_url("less_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than or equal to 3","type": "value_error.number.not_le","ctx": {"limit_value": 3},}]})def test_path_param_lt_int_2():response = client.get("/path/param-lt-int/2")assert response.status_code == 200assert response.json() == 2def test_path_param_lt_int_42():response = client.get("/path/param-lt-int/42")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than","loc": ["path", "item_id"],"msg": "Input should be less than 3","input": "42","ctx": {"lt": 3},"url": match_pydantic_error_url("less_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than 3","type": "value_error.number.not_lt","ctx": {"limit_value": 3},}]})def test_path_param_lt_int_2_7():response = client.get("/path/param-lt-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_param_gt_int_42():response = client.get("/path/param-gt-int/42")assert response.status_code == 200assert response.json() == 42def test_path_param_gt_int_2():response = client.get("/path/param-gt-int/2")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than","loc": ["path", "item_id"],"msg": "Input should be greater than 3","input": "2","ctx": {"gt": 3},"url": match_pydantic_error_url("greater_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than 3","type": "value_error.number.not_gt","ctx": {"limit_value": 3},}]})def test_path_param_gt_int_2_7():response = client.get("/path/param-gt-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_param_le_int_42():response = client.get("/path/param-le-int/42")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than_equal","loc": ["path", "item_id"],"msg": "Input should be less than or equal to 3","input": "42","ctx": {"le": 3},"url": match_pydantic_error_url("less_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than or equal to 3","type": "value_error.number.not_le","ctx": {"limit_value": 3},}]})def test_path_param_le_int_3():response = client.get("/path/param-le-int/3")assert response.status_code == 200assert response.json() == 3def test_path_param_le_int_2():response = client.get("/path/param-le-int/2")assert response.status_code == 200assert response.json() == 2def test_path_param_le_int_2_7():response = client.get("/path/param-le-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_param_ge_int_42():response = client.get("/path/param-ge-int/42")assert response.status_code == 200assert response.json() == 42def test_path_param_ge_int_3():response = client.get("/path/param-ge-int/3")assert response.status_code == 200assert response.json() == 3def test_path_param_ge_int_2():response = client.get("/path/param-ge-int/2")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than_equal","loc": ["path", "item_id"],"msg": "Input should be greater than or equal to 3","input": "2","ctx": {"ge": 3},"url": match_pydantic_error_url("greater_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than or equal to 3","type": "value_error.number.not_ge","ctx": {"limit_value": 3},}]})def test_path_param_ge_int_2_7():response = client.get("/path/param-ge-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_param_lt_gt_int_2():response = client.get("/path/param-lt-gt-int/2")assert response.status_code == 200assert response.json() == 2def test_path_param_lt_gt_int_4():response = client.get("/path/param-lt-gt-int/4")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than","loc": ["path", "item_id"],"msg": "Input should be less than 3","input": "4","ctx": {"lt": 3},"url": match_pydantic_error_url("less_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than 3","type": "value_error.number.not_lt","ctx": {"limit_value": 3},}]})def test_path_param_lt_gt_int_0():response = client.get("/path/param-lt-gt-int/0")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "greater_than","loc": ["path", "item_id"],"msg": "Input should be greater than 1","input": "0","ctx": {"gt": 1},"url": match_pydantic_error_url("greater_than"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is greater than 1","type": "value_error.number.not_gt","ctx": {"limit_value": 1},}]})def test_path_param_lt_gt_int_2_7():response = client.get("/path/param-lt-gt-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})def test_path_param_le_ge_int_2():response = client.get("/path/param-le-ge-int/2")assert response.status_code == 200assert response.json() == 2def test_path_param_le_ge_int_1():response = client.get("/path/param-le-ge-int/1")assert response.status_code == 200assert response.json() == 1def test_path_param_le_ge_int_3():response = client.get("/path/param-le-ge-int/3")assert response.status_code == 200assert response.json() == 3def test_path_param_le_ge_int_4():response = client.get("/path/param-le-ge-int/4")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "less_than_equal","loc": ["path", "item_id"],"msg": "Input should be less than or equal to 3","input": "4","ctx": {"le": 3},"url": match_pydantic_error_url("less_than_equal"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "ensure this value is less than or equal to 3","type": "value_error.number.not_le","ctx": {"limit_value": 3},}]})def test_path_param_le_ge_int_2_7():response = client.get("/path/param-le-ge-int/2.7")assert response.status_code == 422assert response.json() == IsDict({"detail": [{"type": "int_parsing","loc": ["path", "item_id"],"msg": "Input should be a valid integer, unable to parse string as an integer","input": "2.7","url": match_pydantic_error_url("int_parsing"),}]}) | IsDict(# TODO: remove when deprecating Pydantic v1{"detail": [{"loc": ["path", "item_id"],"msg": "value is not a valid integer","type": "type_error.integer",}]})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。