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)
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})
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
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