示例#1
0
def test_warning():
    example = {"name": "John"}
    endpoint = make_endpoint(**{"query": {"example": example}})
    with pytest.warns(None) as record:
        assert list(
            get_examples(endpoint)) == [make_case(**{"query": example})]
    assert not record
示例#2
0
def test_no_body_in_get():
    endpoint = Endpoint(
        path="/api/success",
        method="GET",
        definition={},
        query={
            "required": ["name"],
            "type": "object",
            "additionalProperties": False,
            "properties": {"name": {"type": "string"}},
            "example": {"name": "John"},
        },
    )
    assert list(get_examples(endpoint))[0].body is None
示例#3
0
def test_get_examples(name):
    example = {"name": "John"}
    endpoint = make_endpoint(
        **{
            name: {
                "required": ["name"],
                "type": "object",
                "additionalProperties": False,
                "properties": {"name": {"type": "string"}},
                "example": example,
            }
        }
    )
    assert list(get_examples(endpoint)) == [make_case(**{name: example})]
示例#4
0
def test_warning(swagger_20):
    example = {"name": "John"}
    endpoint = make_endpoint(swagger_20, query={"example": example})
    with pytest.warns(None) as record:
        assert list(get_examples(endpoint)) == [Case(endpoint, query=example)]
    assert not record