Ejemplo n.º 1
0
def test_examples_validity(schema, base_url):
    strategy = get_example(schema.endpoints["/api/success"]["get"])

    @given(case=strategy)
    def test(case):
        # Generated examples should have valid parameters
        # E.g. headers should be latin-1 encodable
        case.call(base_url=base_url)
Ejemplo n.º 2
0
def test_get_examples(name, swagger_20):
    example = {"name": "John"}
    endpoint = make_endpoint(
        swagger_20,
        **{
            name: {
                "required": ["name"],
                "type": "object",
                "additionalProperties": False,
                "properties": {
                    "name": {
                        "type": "string"
                    }
                },
                "example": example,
            }
        },
    )
    assert get_example(endpoint) == Case(endpoint, **{name: example})
Ejemplo n.º 3
0
def test_no_body_in_get(swagger_20):
    endpoint = Endpoint(
        path="/api/success",
        method="GET",
        definition={},
        schema=swagger_20,
        query={
            "required": ["name"],
            "type": "object",
            "additionalProperties": False,
            "properties": {
                "name": {
                    "type": "string"
                }
            },
            "example": {
                "name": "John"
            },
        },
    )
    assert get_example(endpoint).body is None
Ejemplo n.º 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 get_example(endpoint) == Case(endpoint, query=example)
    assert not record