@@ -187,6 +187,57 @@ def test_to_gbq_with_verbose_old_pandas_no_warnings(recwarn, min_bq_version):
187
187
assert len (recwarn ) == 0
188
188
189
189
190
+ def test_to_gbq_with_private_key_new_pandas_warns_deprecation (
191
+ min_bq_version , monkeypatch
192
+ ):
193
+ import pkg_resources
194
+ from pandas_gbq import auth
195
+
196
+ monkeypatch .setattr (auth , "get_credentials" , mock_get_credentials )
197
+
198
+ pandas_version = pkg_resources .parse_version ("0.24.0" )
199
+ with pytest .warns (FutureWarning ), mock .patch (
200
+ "pkg_resources.Distribution.parsed_version" ,
201
+ new_callable = mock .PropertyMock ,
202
+ ) as mock_version :
203
+ mock_version .side_effect = [min_bq_version , pandas_version ]
204
+ try :
205
+ gbq .to_gbq (
206
+ DataFrame ([[1 ]]),
207
+ "dataset.tablename" ,
208
+ project_id = "my-project" ,
209
+ private_key = "path/to/key.json" ,
210
+ )
211
+ except gbq .TableCreationError :
212
+ pass
213
+
214
+
215
+ def test_to_gbq_with_private_key_old_pandas_no_warnings (
216
+ recwarn , min_bq_version , monkeypatch
217
+ ):
218
+ import pkg_resources
219
+ from pandas_gbq import auth
220
+
221
+ monkeypatch .setattr (auth , "get_credentials" , mock_get_credentials )
222
+
223
+ pandas_version = pkg_resources .parse_version ("0.23.4" )
224
+ with mock .patch (
225
+ "pkg_resources.Distribution.parsed_version" ,
226
+ new_callable = mock .PropertyMock ,
227
+ ) as mock_version :
228
+ mock_version .side_effect = [min_bq_version , pandas_version ]
229
+ try :
230
+ gbq .to_gbq (
231
+ DataFrame ([[1 ]]),
232
+ "dataset.tablename" ,
233
+ project_id = "my-project" ,
234
+ private_key = "path/to/key.json" ,
235
+ )
236
+ except gbq .TableCreationError :
237
+ pass
238
+ assert len (recwarn ) == 0
239
+
240
+
190
241
def test_to_gbq_doesnt_run_query (
191
242
recwarn , mock_bigquery_client , min_bq_version
192
243
):
@@ -334,6 +385,48 @@ def test_read_gbq_with_verbose_old_pandas_no_warnings(recwarn, min_bq_version):
334
385
assert len (recwarn ) == 0
335
386
336
387
388
+ def test_read_gbq_with_private_key_new_pandas_warns_deprecation (
389
+ min_bq_version , monkeypatch
390
+ ):
391
+ import pkg_resources
392
+ from pandas_gbq import auth
393
+
394
+ monkeypatch .setattr (auth , "get_credentials" , mock_get_credentials )
395
+
396
+ pandas_version = pkg_resources .parse_version ("0.24.0" )
397
+ with pytest .warns (FutureWarning ), mock .patch (
398
+ "pkg_resources.Distribution.parsed_version" ,
399
+ new_callable = mock .PropertyMock ,
400
+ ) as mock_version :
401
+ mock_version .side_effect = [min_bq_version , pandas_version ]
402
+ gbq .read_gbq (
403
+ "SELECT 1" , project_id = "my-project" , private_key = "path/to/key.json"
404
+ )
405
+
406
+
407
+ def test_read_gbq_with_private_key_old_pandas_no_warnings (
408
+ recwarn , min_bq_version , monkeypatch
409
+ ):
410
+ import pkg_resources
411
+ from pandas_gbq import auth
412
+
413
+ monkeypatch .setattr (auth , "get_credentials" , mock_get_credentials )
414
+
415
+ pandas_version = pkg_resources .parse_version ("0.23.4" )
416
+ with mock .patch (
417
+ "pkg_resources.Distribution.parsed_version" ,
418
+ new_callable = mock .PropertyMock ,
419
+ ) as mock_version :
420
+ mock_version .side_effect = [min_bq_version , pandas_version ]
421
+ gbq .read_gbq (
422
+ "SELECT 1" ,
423
+ project_id = "my-project" ,
424
+ dialect = "standard" ,
425
+ private_key = "path/to/key.json" ,
426
+ )
427
+ assert len (recwarn ) == 0
428
+
429
+
337
430
def test_read_gbq_with_invalid_dialect ():
338
431
with pytest .raises (ValueError ) as excinfo :
339
432
gbq .read_gbq ("SELECT 1" , dialect = "invalid" )
0 commit comments