#NEWLINE# def testClientPrioritization( self ) : #NEWLINE# #INDENT# 'Test that flow priorities work on the client side.' #NEWLINE# result = [ ] #NEWLINE# client_mock = PriorityClientMock ( result ) #NEWLINE# client_mock = test_lib . MockClient ( self . client_id , client_mock , token = self . token ) #NEWLINE# worker_mock = test_lib . MockWorker ( check_flow_errors = True , token = self . token ) #NEWLINE# args = [ ( rdf_flows . GrrMessage . Priority . LOW_PRIORITY , 'low priority' ) , ( rdf_flows . GrrMessage . Priority . MEDIUM_PRIORITY , 'medium priority' ) , ( rdf_flows . GrrMessage . Priority . LOW_PRIORITY , 'low priority2' ) , ( rdf_flows . GrrMessage . Priority . HIGH_PRIORITY , 'high priority' ) , ( rdf_flows . GrrMessage . Priority . MEDIUM_PRIORITY , 'medium priority2' ) ] #NEWLINE# for ( priority , msg ) in args : #NEWLINE# #INDENT# flow . GRRFlow . StartFlow ( client_id = self . client_id , flow_name = 'PriorityFlow' , msg = msg , priority = priority , token = self . token ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# client_processed = client_mock . Next ( ) #NEWLINE# flows_run = [ ] #NEWLINE# for flow_run in worker_mock . Next ( ) : #NEWLINE# #INDENT# flows_run . append ( flow_run ) #NEWLINE# #UNINDENT# if ( ( client_processed == 0 ) and ( not flows_run ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( flow_run [ 0 : 1 ] , [ 'high priority' ] ) #NEWLINE# self . assertEqual ( sorted ( result [ 1 : 3 ] ) , [ 'medium priority' , 'medium priority2' ] ) #NEWLINE# self . assertEqual ( sorted ( result [ 3 : 5 ] ) , [ 'low priority' , 'low priority2' ] )