#NEWLINE# def test_insert_data_w_repeated_fields( self ) : #NEWLINE# #INDENT# from gcloud.bigquery.table import SchemaField #NEWLINE# PATH = ( 'projects/%s/datasets/%s/tables/%s/insertAll' % ( self . PROJECT , self . DS_NAME , self . TABLE_NAME ) ) #NEWLINE# conn = _Connection ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# client = _Client ( project = self . PROJECT , connection = conn ) #NEWLINE# dataset = _Dataset ( client ) #NEWLINE# full_name = SchemaField ( 'color' , 'STRING' , mode = 'REPEATED' ) #NEWLINE# index = SchemaField ( 'index' , 'INTEGER' , 'REPEATED' ) #NEWLINE# score = SchemaField ( 'score' , 'FLOAT' , 'REPEATED' ) #NEWLINE# struct = SchemaField ( 'struct' , 'RECORD' , mode = 'REPEATED' , fields = [ index , score ] ) #NEWLINE# table = self . _makeOne ( self . TABLE_NAME , dataset = dataset , schema = [ full_name , struct ] ) #NEWLINE# ROWS = [ ( [ 'red' , 'green' ] , [ { #NEWLINE# #INDENT# 'index' : [ 1 , 2 ] , #NEWLINE# 'score' : [ 3.1415 , 1.414 ] , #NEWLINE# #UNINDENT# } ] ) ] #NEWLINE# def _row_data( row ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'color' : row [ 0 ] , #NEWLINE# 'struct' : row [ 1 ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# SENT = { #NEWLINE# #INDENT# 'rows' : [ { #NEWLINE# #INDENT# 'json' : _row_data ( row ) , #NEWLINE# #UNINDENT# } for row in ROWS ] , #NEWLINE# #UNINDENT# } #NEWLINE# errors = table . insert_data ( ROWS ) #NEWLINE# self . assertEqual ( len ( errors ) , 0 ) #NEWLINE# self . assertEqual ( len ( conn . _requested ) , 1 ) #NEWLINE# req = conn . _requested [ 0 ] #NEWLINE# self . assertEqual ( req [ 'method' ] , 'POST' ) #NEWLINE# self . assertEqual ( req [ 'path' ] , ( '/%s' % PATH ) ) #NEWLINE# self . assertEqual ( req [ 'data' ] , SENT )