def TestFlowHelper(flow_urn_or_cls_name, client_mock=None, client_id=None, check_flow_errors=True, token=None, notification_event=None, sync=True, **kwargs):
 if (client_id or client_mock):
  client_mock = MockClient(client_id, client_mock, token=token)
 worker_mock = MockWorker(check_flow_errors=check_flow_errors, token=token)
 if isinstance(flow_urn_or_cls_name, rdfvalue.RDFURN):
  session_id = flow_urn_or_cls_name
 else:
  session_id = flow.GRRFlow.StartFlow(client_id=client_id, flow_name=flow_urn_or_cls_name, notification_event=notification_event, sync=sync, token=token, **kwargs)
 total_flows = set()
 total_flows.add(session_id)
 while True:
  if client_mock:
   client_processed = client_mock.Next()
  else:
   client_processed = 0
  flows_run = []
  for flow_run in worker_mock.Next():
   total_flows.add(flow_run)
   flows_run.append(flow_run)
  if ((client_processed == 0) and (not flows_run)):
   break
  (yield session_id)
 if check_flow_errors:
  CheckFlowErrors(total_flows, token=token)

def TestFlowHelper ( flow_urn_or_cls_name , client_mock = None , client_id = None , check_flow_errors = True , token = None , notification_event = None , sync = True , ** kwargs ) : if ( client_id or client_mock ) : client_mock = MockClient ( client_id , client_mock , token = token ) worker_mock = MockWorker ( check_flow_errors = check_flow_errors , token = token ) if isinstance ( flow_urn_or_cls_name , rdfvalue . RDFURN ) : session_id = flow_urn_or_cls_name else : session_id = flow . GRRFlow . StartFlow ( client_id = client_id , flow_name = flow_urn_or_cls_name , notification_event = notification_event , sync = sync , token = token , ** kwargs ) total_flows = set ( ) total_flows . add ( session_id ) while True : if client_mock : client_processed = client_mock . Next ( ) else : client_processed = 0 flows_run = [ ] for flow_run in worker_mock . Next ( ) : total_flows . add ( flow_run ) flows_run . append ( flow_run ) if ( ( client_processed == 0 ) and ( not flows_run ) ) : break ( yield session_id ) if check_flow_errors : CheckFlowErrors ( total_flows , token = token )
build a full test harness: client - worker + start flow .