#NEWLINE# def test_update_w_alternate_client( self ) : #NEWLINE# #INDENT# import datetime #NEWLINE# from gcloud._helpers import UTC #NEWLINE# from gcloud._helpers import _millis #NEWLINE# from gcloud.bigquery.table import SchemaField #NEWLINE# PATH = ( 'projects/%s/datasets/%s/tables/%s' % ( self . PROJECT , self . DS_NAME , self . TABLE_NAME ) ) #NEWLINE# DEF_TABLE_EXP = 12345 #NEWLINE# LOCATION = 'EU' #NEWLINE# QUERY = 'select fullname, age from person_ages' #NEWLINE# RESOURCE = self . _makeResource ( ) #NEWLINE# RESOURCE [ 'defaultTableExpirationMs' ] = 12345 #NEWLINE# RESOURCE [ 'location' ] = LOCATION #NEWLINE# self . EXP_TIME = datetime . datetime ( 2015 , 8 , 1 , 23 , 59 , 59 , tzinfo = UTC ) #NEWLINE# RESOURCE [ 'expirationTime' ] = _millis ( self . EXP_TIME ) #NEWLINE# RESOURCE [ 'view' ] = { #NEWLINE# #INDENT# 'query' : QUERY , #NEWLINE# #UNINDENT# } #NEWLINE# RESOURCE [ 'type' ] = 'VIEW' #NEWLINE# conn1 = _Connection ( ) #NEWLINE# client1 = _Client ( project = self . PROJECT , connection = conn1 ) #NEWLINE# conn2 = _Connection ( RESOURCE ) #NEWLINE# client2 = _Client ( project = self . PROJECT , connection = conn2 ) #NEWLINE# dataset = _Dataset ( client1 ) #NEWLINE# table = self . _makeOne ( self . TABLE_NAME , dataset = dataset ) #NEWLINE# table . default_table_expiration_ms = DEF_TABLE_EXP #NEWLINE# table . location = LOCATION #NEWLINE# table . expires = self . EXP_TIME #NEWLINE# table . view_query = QUERY #NEWLINE# table . update ( 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' ] , 'PUT' ) #NEWLINE# self . assertEqual ( req [ 'path' ] , ( '/%s' % PATH ) ) #NEWLINE# SENT = { #NEWLINE# #INDENT# 'tableReference' : { #NEWLINE# #INDENT# 'projectId' : self . PROJECT , #NEWLINE# 'datasetId' : self . DS_NAME , #NEWLINE# 'tableId' : self . TABLE_NAME , #NEWLINE# #UNINDENT# } , #NEWLINE# 'expirationTime' : _millis ( self . EXP_TIME ) , #NEWLINE# 'location' : 'EU' , #NEWLINE# 'view' : { #NEWLINE# #INDENT# 'query' : QUERY , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( req [ 'data' ] , SENT ) #NEWLINE# self . _verifyResourceProperties ( table , RESOURCE )