#NEWLINE# @ patch ( 'google.cloud.dataflow.worker.batchworker.workitem' ) #NEWLINE# @ patch . object ( apiclient . DataflowWorkerClient , 'lease_work' ) #NEWLINE# def test_worker_requests_for_work( self , mock_lease_work , mock_workitem ) : #NEWLINE# #INDENT# worker = batchworker . BatchWorker ( self . dummy_properties ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# rand_work = object ( ) #NEWLINE# mock_lease_work . return_value = rand_work #NEWLINE# mock_workitem . get_work_items . return_value = None #NEWLINE# thread = threading . Thread ( target = mock_workitem . run ) #NEWLINE# thread . start ( ) #NEWLINE# time . sleep ( 5 ) #NEWLINE# worker . shutdown ( ) #NEWLINE# mock_lease_work . assert_called_with ( mock . ANY , worker . default_desired_lease_duration ( ) ) #NEWLINE# mock_workitem . get_work_items . assert_called_with ( rand_work , mock . ANY , mock . ANY )