def test_object_with_no_serialize_wrapper() -> None: """ Test if an object that is Serializable but does not implement the serializable_wrapper_type throws an exception when trying to serialize. """ class TestObject(Serializable): pass with pytest.raises(Exception): _serialize(TestObject())
def syft_multipart_route(): # grid relative from ...core.node import get_node # TODO: fix circular import if "file" not in request.files: response = {"error": "Invalid message!"} status_code = 403 file_obj = request.files["file"] msg = file_obj.stream.read() obj_msg = deserialize(blob=msg, from_bytes=True) if isinstance(obj_msg, SignedImmediateSyftMessageWithReply): reply = get_node().recv_immediate_msg_with_reply(msg=obj_msg) r = Response(response=_serialize(obj=reply, to_bytes=True), status=200) r.headers["Content-Type"] = "application/octet-stream" del msg del obj_msg return r elif isinstance(obj_msg, SignedImmediateSyftMessageWithoutReply): get_node().recv_immediate_msg_without_reply(msg=obj_msg) else: get_node().recv_eventual_msg_without_reply(msg=obj_msg) return ""
def root_route(): data = request.get_data() obj_msg = deserialize(blob=data, from_bytes=True) if isinstance(obj_msg, SignedImmediateSyftMessageWithReply): reply = get_node().recv_immediate_msg_with_reply(msg=obj_msg) r = Response(response=_serialize(obj=reply, to_bytes=True), status=200) r.headers["Content-Type"] = "application/octet-stream" return r elif isinstance(obj_msg, SignedImmediateSyftMessageWithoutReply): get_node().recv_immediate_msg_without_reply(msg=obj_msg) else: get_node().recv_eventual_msg_without_reply(msg=obj_msg) return ""
def root_route(): # grid relative from ...core.node import get_node # TODO: fix circular import data = request.get_data() obj_msg = deserialize(blob=data, from_bytes=True) get_node().sender_request = request.remote_addr if isinstance(obj_msg, SignedImmediateSyftMessageWithReply): reply = get_node().recv_immediate_msg_with_reply(msg=obj_msg) r = Response(response=_serialize(obj=reply, to_bytes=True), status=200) r.headers["Content-Type"] = "application/octet-stream" return r elif isinstance(obj_msg, SignedImmediateSyftMessageWithoutReply): get_node().recv_immediate_msg_without_reply(msg=obj_msg) else: get_node().recv_eventual_msg_without_reply(msg=obj_msg) return ""