@@ -280,53 +280,31 @@ def test_get_user_account_credentials_returns_credentials(self):
280
280
assert isinstance (credentials , Credentials )
281
281
282
282
283
- @pytest .mark .skip ('Currently fails, see '
284
- 'https://github.com/pydata/pandas-gbq/pull/125' )
285
283
class TestGBQUnit (object ):
286
284
287
- def test_import_google_api_python_client (self ):
288
- if not _in_travis_environment ():
289
- pytest .skip ("Skip if not in travis environment. Extra test to "
290
- "make sure pandas_gbq doesn't break when "
291
- "using google-api-python-client==1.2" )
292
-
293
- if compat .PY2 :
294
- with pytest .raises (ImportError ):
295
- from googleapiclient .discovery import build # noqa
296
- from googleapiclient .errors import HttpError # noqa
297
- from apiclient .discovery import build # noqa
298
- from apiclient .errors import HttpError # noqa
299
- else :
300
- from googleapiclient .discovery import build # noqa
301
- from googleapiclient .errors import HttpError # noqa
302
-
303
285
def test_should_return_credentials_path_set_by_env_var (self ):
304
286
305
287
env = {'PANDAS_GBQ_CREDENTIALS_FILE' : '/tmp/dummy.dat' }
306
288
with mock .patch .dict ('os.environ' , env ):
307
289
assert gbq ._get_credentials_file () == '/tmp/dummy.dat'
308
290
309
- assert gbq ._get_credentials_file () == 'bigquery_credentials.dat'
310
-
311
- def test_should_return_bigquery_integers_as_python_ints (self ):
312
- result = gbq ._parse_entry (1 , 'INTEGER' )
313
- assert result == int (1 )
314
-
315
- def test_should_return_bigquery_floats_as_python_floats (self ):
316
- result = gbq ._parse_entry (1 , 'FLOAT' )
317
- assert result == float (1 )
318
-
319
- def test_should_return_bigquery_timestamps_as_numpy_datetime (self ):
320
- result = gbq ._parse_entry ('0e9' , 'TIMESTAMP' )
321
- assert result == np_datetime64_compat ('1970-01-01T00:00:00Z' )
322
-
323
- def test_should_return_bigquery_booleans_as_python_booleans (self ):
324
- result = gbq ._parse_entry ('false' , 'BOOLEAN' )
325
- assert not result
326
-
327
- def test_should_return_bigquery_strings_as_python_strings (self ):
328
- result = gbq ._parse_entry ('STRING' , 'STRING' )
329
- assert result == 'STRING'
291
+ @pytest .mark .parametrize (
292
+ ('input' , 'type_' , 'expected' ), [
293
+ (1 , 'INTEGER' , int (1 )),
294
+ (1 , 'FLOAT' , float (1 )),
295
+ pytest .param ('false' , 'BOOLEAN' , False , marks = pytest .mark .xfail ),
296
+ pytest .param (
297
+ '0e9' , 'TIMESTAMP' ,
298
+ np_datetime64_compat ('1970-01-01T00:00:00Z' ),
299
+ marks = pytest .mark .xfail ),
300
+ ('STRING' , 'STRING' , 'STRING' ),
301
+ ])
302
+ def test_should_return_bigquery_correctly_typed (
303
+ self , input , type_ , expected ):
304
+ result = gbq ._parse_data (
305
+ dict (fields = [dict (name = 'x' , type = type_ , mode = 'NULLABLE' )]),
306
+ rows = [[input ]]).iloc [0 , 0 ]
307
+ assert result == expected
330
308
331
309
def test_to_gbq_should_fail_if_invalid_table_name_passed (self ):
332
310
with pytest .raises (gbq .NotFoundException ):
@@ -893,7 +871,7 @@ def test_array_of_floats(self):
893
871
private_key = _get_private_key_path (),
894
872
dialect = 'standard' )
895
873
tm .assert_frame_equal (df , DataFrame ([[[1.1 , 2.2 , 3.3 ], 4 ]],
896
- columns = ["a" , "b" ]))
874
+ columns = ["a" , "b" ]))
897
875
898
876
899
877
class TestToGBQIntegration (object ):
0 commit comments