Example #1
0
def test_parse_resp():
    assert parse_resp(undecorated_func) == {}
    resp_spec = parse_resp(demo_func)

    assert resp_spec["422"]["description"] == "Unprocessable Entity"
    assert (resp_spec["422"]["content"]["application/json"]["schema"]["$ref"]
            == "#/components/schemas/UnprocessableEntity")
    assert (resp_spec["200"]["content"]["application/json"]["schema"]["$ref"]
            == "#/components/schemas/DemoModel")
Example #2
0
def test_parse_resp():
    assert parse_resp(undecorated_func) == {}
    assert parse_resp(demo_class.demo_method) == {
        '422': {
            'description': 'Validation Error'
        }
    }
    resp_spec = parse_resp(demo_func)
    assert resp_spec['422']['description'] == 'Validation Error'
    assert resp_spec['200']['content']['application/json']['schema']['$ref'] \
        == '#/components/schemas/DemoModel'
Example #3
0
def test_parse_resp():
    assert parse_resp(undecorated_func) == {}
    resp_spec = parse_resp(demo_func)

    assert resp_spec["422"]["description"] == "Unprocessable Entity"
    model_path_key = get_model_path_key("spectree.models.UnprocessableEntity")
    assert (resp_spec["422"]["content"]["application/json"]["schema"]["$ref"]
            == f"#/components/schemas/{model_path_key}")
    model_path_key = get_model_path_key("tests.common.DemoModel")
    assert (resp_spec["200"]["content"]["application/json"]["schema"]["$ref"]
            == f"#/components/schemas/{model_path_key}")
Example #4
0
def test_parse_resp():
    assert parse_resp(undecorated_func, 422) == {}
    assert parse_resp(demo_class.demo_method, 422) == {
        "422": {
            "description": "Validation Error"
        }
    }
    resp_spec = parse_resp(demo_func, 422)
    assert resp_spec["422"]["description"] == "Validation Error"
    assert (resp_spec["200"]["content"]["application/json"]["schema"]["$ref"]
            == "#/components/schemas/DemoModel")

    resp_spec = parse_resp(demo_func, 400)
    assert "422" not in resp_spec
    assert resp_spec["400"]["description"] == "Validation Error"