def test_transport_factory_context(self): node_a, node_b = MockNode(), MockNode() pipe = ZeroPipe(node_a, node_b) transport = mock.MagicMock() prev_method = pipe._transport_factory with pipe.transport_factory_context(transport): assert pipe._transport_factory == transport assert pipe._transport_factory == prev_method
def generate_network(name): transport = ZeroTransport(transport_connectors_factory, serializer=serializer, deserializer=deserializer) with ZeroPipe.transport_factory_context(transport): req_http = ZeroNode(ReqOperator(req_http_op)) req_ftp = ZeroNode(ReqOperator(req_ftp_op)) save = ZeroNode(PythonFunctionOperator(save_op)) http_filter = RegexMatchFilter("^https?://.*") ftp_filter = RegexMatchFilter("^ftp://.*") return ZeroNetwork( [ ZeroPipe(ZeroNode.IN, req_http, filters=[http_filter]), ZeroPipe(ZeroNode.IN, req_ftp, filters=[ftp_filter]), ZeroPipe(req_http, save), ZeroPipe(req_ftp, save), ], _id=name, )