def test_with_invalid_return_type(): with pytest.raises(CanNotInspectReturnType) as e: build_response_schema(Controller.with_invalid_return_type) assert repr(e.value) == ( 'CanNotInspectReturnType(tests.schema.test_build_response_schema.Controller.with_invalid_return_type: ' "-> <class 'object'>: Unknown type: <class 'object'>)")
def test_build_response_schema(return_type, expected_response): @winter.route('') class SimpleController: @winter.route_get('/simple/') def simple_method(self) -> return_type: # pragma: no cover return None # Act schema = build_response_schema(SimpleController.simple_method) # Assert assert isinstance(schema, openapi.SwaggerDict)
def test_with_output_serializer(): schema = build_response_schema(Controller.with_output_serializer) assert isinstance(schema, UserSerializer)