@@ -6739,42 +6739,21 @@ def test_list_rows(self):
67396739self .DS_ID ,
67406740self .TABLE_ID ,
67416741 )
6742- WHEN_TS = 1437767599.006
6743- WHEN = datetime .datetime .utcfromtimestamp (WHEN_TS ).replace (tzinfo = UTC )
6744- WHEN_1 = WHEN + datetime .timedelta (seconds = 1 )
6745- WHEN_2 = WHEN + datetime .timedelta (seconds = 2 )
6742+ WHEN_TS = 1437767599006000
6743+
6744+ WHEN = datetime .datetime .utcfromtimestamp (WHEN_TS / 1e6 ).replace (tzinfo = UTC )
6745+ WHEN_1 = WHEN + datetime .timedelta (microseconds = 1 )
6746+ WHEN_2 = WHEN + datetime .timedelta (microseconds = 2 )
67466747ROWS = 1234
67476748TOKEN = "TOKEN"
67486749
6749- def _bigquery_timestamp_float_repr (ts_float ):
6750- # Preserve microsecond precision for E+09 timestamps
6751- return "%0.15E" % (ts_float ,)
6752-
67536750DATA = {
67546751"totalRows" :str (ROWS ),
67556752"pageToken" :TOKEN ,
67566753"rows" : [
6757- {
6758- "f" : [
6759- {"v" :"Phred Phlyntstone" },
6760- {"v" :"32" },
6761- {"v" :_bigquery_timestamp_float_repr (WHEN_TS )},
6762- ]
6763- },
6764- {
6765- "f" : [
6766- {"v" :"Bharney Rhubble" },
6767- {"v" :"33" },
6768- {"v" :_bigquery_timestamp_float_repr (WHEN_TS + 1 )},
6769- ]
6770- },
6771- {
6772- "f" : [
6773- {"v" :"Wylma Phlyntstone" },
6774- {"v" :"29" },
6775- {"v" :_bigquery_timestamp_float_repr (WHEN_TS + 2 )},
6776- ]
6777- },
6754+ {"f" : [{"v" :"Phred Phlyntstone" }, {"v" :"32" }, {"v" :WHEN_TS }]},
6755+ {"f" : [{"v" :"Bharney Rhubble" }, {"v" :"33" }, {"v" :WHEN_TS + 1 }]},
6756+ {"f" : [{"v" :"Wylma Phlyntstone" }, {"v" :"29" }, {"v" :WHEN_TS + 2 }]},
67786757 {"f" : [{"v" :"Bhettye Rhubble" }, {"v" :None }, {"v" :None }]},
67796758 ],
67806759 }
@@ -6807,7 +6786,10 @@ def _bigquery_timestamp_float_repr(ts_float):
68076786self .assertEqual (iterator .next_page_token ,TOKEN )
68086787
68096788conn .api_request .assert_called_once_with (
6810- method = "GET" ,path = "/%s" % PATH ,query_params = {},timeout = 7.5
6789+ method = "GET" ,
6790+ path = "/%s" % PATH ,
6791+ query_params = {"formatOptions.useInt64Timestamp" :True },
6792+ timeout = 7.5 ,
68116793 )
68126794
68136795def test_list_rows_w_start_index_w_page_size (self ):
@@ -6856,20 +6838,30 @@ def test_list_rows_w_start_index_w_page_size(self):
68566838self .assertEqual (len (rows ),2 )
68576839self .assertEqual (rows [0 ],Row (("Wylma Phlyntstone" ,),f2i ))
68586840self .assertEqual (rows [1 ],Row (("Bhettye Rhubble" ,),f2i ))
6859- self .assertEqual (extra_params , {"startIndex" :1 })
6841+ self .assertEqual (
6842+ extra_params , {"startIndex" :1 ,"formatOptions.useInt64Timestamp" :True }
6843+ )
68606844
68616845conn .api_request .assert_has_calls (
68626846 [
68636847mock .call (
68646848method = "GET" ,
68656849path = "/%s" % PATH ,
6866- query_params = {"startIndex" :1 ,"maxResults" :2 },
6850+ query_params = {
6851+ "startIndex" :1 ,
6852+ "maxResults" :2 ,
6853+ "formatOptions.useInt64Timestamp" :True ,
6854+ },
68676855timeout = None ,
68686856 ),
68696857mock .call (
68706858method = "GET" ,
68716859path = "/%s" % PATH ,
6872- query_params = {"pageToken" :"some-page-token" ,"maxResults" :2 },
6860+ query_params = {
6861+ "pageToken" :"some-page-token" ,
6862+ "maxResults" :2 ,
6863+ "formatOptions.useInt64Timestamp" :True ,
6864+ },
68736865timeout = None ,
68746866 ),
68756867 ]
@@ -6920,6 +6912,7 @@ def test_list_rows_query_params(self):
69206912iterator = client .list_rows (table ,** test [0 ])
69216913six .next (iterator .pages )
69226914req = conn .api_request .call_args_list [i ]
6915+ test [1 ]["formatOptions.useInt64Timestamp" ]= True
69236916self .assertEqual (req [1 ]["query_params" ],test [1 ],"for kwargs %s" % test [0 ])
69246917
69256918def test_list_rows_repeated_fields (self ):
@@ -6979,7 +6972,10 @@ def test_list_rows_repeated_fields(self):
69796972conn .api_request .assert_called_once_with (
69806973method = "GET" ,
69816974path = "/%s" % PATH ,
6982- query_params = {"selectedFields" :"color,struct" },
6975+ query_params = {
6976+ "selectedFields" :"color,struct" ,
6977+ "formatOptions.useInt64Timestamp" :True ,
6978+ },
69836979timeout = None ,
69846980 )
69856981
@@ -7047,7 +7043,10 @@ def test_list_rows_w_record_schema(self):
70477043self .assertEqual (page_token ,TOKEN )
70487044
70497045conn .api_request .assert_called_once_with (
7050- method = "GET" ,path = "/%s" % PATH ,query_params = {},timeout = None
7046+ method = "GET" ,
7047+ path = "/%s" % PATH ,
7048+ query_params = {"formatOptions.useInt64Timestamp" :True },
7049+ timeout = None ,
70517050 )
70527051
70537052def test_list_rows_with_missing_schema (self ):
@@ -7109,7 +7108,10 @@ def test_list_rows_with_missing_schema(self):
71097108
71107109rows = list (row_iter )
71117110conn .api_request .assert_called_once_with (
7112- method = "GET" ,path = tabledata_path ,query_params = {},timeout = None
7111+ method = "GET" ,
7112+ path = tabledata_path ,
7113+ query_params = {"formatOptions.useInt64Timestamp" :True },
7114+ timeout = None ,
71137115 )
71147116self .assertEqual (row_iter .total_rows ,3 ,msg = repr (table ))
71157117self .assertEqual (rows [0 ].name ,"Phred Phlyntstone" ,msg = repr (table ))