Exemple #1
0
class _Resource1(Resource):
    
    schema = _r1_schema
    
    @operation(
        params = {"id": _r1_schema.properties["id"], "_body": _r1_schema},
        returns = s.dict({"id": _r1_schema.properties["id"]}),
        security = [],
    )
    def create(self, id, _body):
        return {"id": id}

    @operation(
        params = {"id": _r1_schema.properties["id"], "_body": _r1_schema},
        security = [],
    )
    def update(self, id, _body):
        return

    @operation(
        type = "action",
        params = {},
        returns = s.str(format="raw"),
        security = [http1]
    )
    def foo(self):
        return "foo_success"

    @operation(
        type = "action",
        params = {"uuid": s.uuid()},
        security = [http1],
    )
    def validate_uuid(self, uuid):
        pass

    @operation(
        type = "action",
        params = {"_body": s.reader()},
        returns = s.reader(),
        security = [],
    )
    def echo(self, _body):
        return BytesIO(_body.read())

    @operation(
        type = "query",
        params = {"optional": s.str()},
        returns = s.str(),
        security = [],
    )
    def optional(self, optional="default"):
        return optional
Exemple #2
0
class TestResource(Resource):
    @operation(params={"_body": s.bytes(format="binary")},
               returns=s.dict({"id": s.str()}))
    def create(self, _body):
        if _body != b"hello_body":
            raise BadRequest("_body not hello_body")
        return {"id": "foo"}

    @operation(type="action",
               params={
                   "a_a": s.int(),
                   "b": s.str()
               },
               returns=s.str())
    def foo(self, a_a, b):
        return "hoot"

    @operation(type="action", params={"_body": s.reader()}, returns=s.reader())
    def echo(self, _body):
        return BytesIO(_body.read())
Exemple #3
0
 def echo(self, _body: s.reader()) -> s.reader():
     return io.BytesIO(_body.read())
Exemple #4
0
 def test_reader_validate_type_error(self):
     self._error(s.reader().validate, "this_is_not_a_reader_object")
Exemple #5
0
 def test_reader_validate_type_success(self):
     s.reader().validate(BytesIO())