#NEWLINE# def test_begin_w_alternate_client( self ) : #NEWLINE# #INDENT# PATH = ( 'projects/%s/jobs' % self . PROJECT ) #NEWLINE# RESOURCE = self . _makeResource ( ended = True ) #NEWLINE# EXTRACT_CONFIGURATION = { #NEWLINE# #INDENT# 'sourceTable' : { #NEWLINE# #INDENT# 'projectId' : self . PROJECT , #NEWLINE# 'datasetId' : self . DS_NAME , #NEWLINE# 'tableId' : self . SOURCE_TABLE , #NEWLINE# #UNINDENT# } , #NEWLINE# 'destinationUris' : [ self . DESTINATION_URI ] , #NEWLINE# 'compression' : 'GZIP' , #NEWLINE# 'destinationFormat' : 'NEWLINE_DELIMITED_JSON' , #NEWLINE# 'fieldDelimiter' : '|' , #NEWLINE# 'printHeader' : False , #NEWLINE# #UNINDENT# } #NEWLINE# RESOURCE [ 'configuration' ] [ 'extract' ] = EXTRACT_CONFIGURATION #NEWLINE# conn1 = _Connection ( ) #NEWLINE# client1 = _Client ( project = self . PROJECT , connection = conn1 ) #NEWLINE# conn2 = _Connection ( RESOURCE ) #NEWLINE# client2 = _Client ( project = self . PROJECT , connection = conn2 ) #NEWLINE# source = _Table ( self . SOURCE_TABLE ) #NEWLINE# job = self . _makeOne ( self . JOB_NAME , source , [ self . DESTINATION_URI ] , client1 ) #NEWLINE# job . compression = 'GZIP' #NEWLINE# job . destination_format = 'NEWLINE_DELIMITED_JSON' #NEWLINE# job . field_delimiter = '|' #NEWLINE# job . print_header = False #NEWLINE# job . begin ( client = client2 ) #NEWLINE# self . assertEqual ( len ( conn1 . _requested ) , 0 ) #NEWLINE# self . assertEqual ( len ( conn2 . _requested ) , 1 ) #NEWLINE# req = conn2 . _requested [ 0 ] #NEWLINE# self . assertEqual ( req [ 'method' ] , 'POST' ) #NEWLINE# self . assertEqual ( req [ 'path' ] , ( '/%s' % PATH ) ) #NEWLINE# SENT = { #NEWLINE# #INDENT# 'jobReference' : { #NEWLINE# #INDENT# 'projectId' : self . PROJECT , #NEWLINE# 'jobId' : self . JOB_NAME , #NEWLINE# #UNINDENT# } , #NEWLINE# 'configuration' : { #NEWLINE# #INDENT# 'extract' : EXTRACT_CONFIGURATION , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( req [ 'data' ] , SENT ) #NEWLINE# self . _verifyResourceProperties ( job , RESOURCE )