@@ -297,7 +297,9 @@ def test_query(self):
297
297
298
298
mock_query_job .execute .return_value = {
299
299
'jobReference' : expected_job_ref ,
300
- 'jobComplete' : True
300
+ 'jobComplete' : True ,
301
+ 'cacheHit' : False ,
302
+ 'totalBytesProcessed' : 0
301
303
}
302
304
303
305
self .mock_job_collection .query .return_value = mock_query_job
@@ -329,6 +331,8 @@ def test_query_max_results_set(self):
329
331
mock_query_job .execute .return_value = {
330
332
'jobReference' : expected_job_ref ,
331
333
'jobComplete' : True ,
334
+ 'cacheHit' : False ,
335
+ 'totalBytesProcessed' : 0
332
336
}
333
337
334
338
self .mock_job_collection .query .return_value = mock_query_job
@@ -357,6 +361,8 @@ def test_query_timeout_set(self):
357
361
mock_query_job .execute .return_value = {
358
362
'jobReference' : expected_job_ref ,
359
363
'jobComplete' : True ,
364
+ 'cacheHit' : False ,
365
+ 'totalBytesProcessed' : 0
360
366
}
361
367
362
368
self .mock_job_collection .query .return_value = mock_query_job
@@ -382,6 +388,8 @@ def test_sync_query_timeout(self):
382
388
mock_query_job .execute .return_value = {
383
389
'jobReference' : expected_job_ref ,
384
390
'jobComplete' : False ,
391
+ 'cacheHit' : False ,
392
+ 'totalBytesProcessed' : 0
385
393
}
386
394
387
395
self .mock_job_collection .query .return_value = mock_query_job
@@ -400,6 +408,8 @@ def test_async_query_timeout(self):
400
408
mock_query_job .execute .return_value = {
401
409
'jobReference' : expected_job_ref ,
402
410
'jobComplete' : False ,
411
+ 'cacheHit' : False ,
412
+ 'totalBytesProcessed' : 0
403
413
}
404
414
405
415
self .mock_job_collection .query .return_value = mock_query_job
@@ -409,14 +419,18 @@ def test_async_query_timeout(self):
409
419
self .assertEquals (results , [])
410
420
411
421
def test_query_dry_run_valid (self ):
412
- """Ensure that None and an empty list is returned from the query when
422
+ """Ensure that None and [cacheHit, totalBytesProcessed] is returned from the query when
413
423
dry_run is True and the query is valid.
414
424
"""
415
425
416
426
mock_query_job = mock .Mock ()
417
427
418
- mock_query_job .execute .return_value = {'jobReference' : {},
419
- 'jobComplete' : True }
428
+ mock_query_job .execute .return_value = {
429
+ 'jobReference' : {},
430
+ 'jobComplete' : True ,
431
+ 'cacheHit' : False ,
432
+ 'totalBytesProcessed' : 0
433
+ }
420
434
421
435
self .mock_job_collection .query .return_value = mock_query_job
422
436
@@ -428,7 +442,7 @@ def test_query_dry_run_valid(self):
428
442
'dryRun' : True }
429
443
)
430
444
self .assertIsNone (job_id )
431
- self .assertEqual ([], results )
445
+ self .assertEqual ([False , 0 ], results )
432
446
433
447
def test_query_dry_run_invalid (self ):
434
448
"""Ensure that None and a dict is returned from the query when dry_run
@@ -468,6 +482,8 @@ def test_query_with_results(self):
468
482
'schema' : {'fields' : [{'name' : 'foo' , 'type' : 'INTEGER' }]},
469
483
'rows' : [{'f' : [{'v' : 10 }]}],
470
484
'jobComplete' : True ,
485
+ 'cacheHit' : False ,
486
+ 'totalBytesProcessed' : 0
471
487
}
472
488
473
489
self .mock_job_collection .query .return_value = mock_query_job
@@ -491,7 +507,9 @@ def test_query_with_using_legacy_sql(self):
491
507
492
508
mock_query_job .execute .return_value = {
493
509
'jobReference' : expected_job_ref ,
494
- 'jobComplete' : True
510
+ 'jobComplete' : True ,
511
+ 'cacheHit' : False ,
512
+ 'totalBytesProcessed' : 0
495
513
}
496
514
497
515
self .mock_job_collection .query .return_value = mock_query_job
@@ -873,7 +891,7 @@ def test_json_job_body_constructed_correctly(self):
873
891
body = {
874
892
"jobReference" : {
875
893
"projectId" : self .project_id ,
876
- "jobId" : "job"
894
+ "jobId" : "job" ,
877
895
},
878
896
"configuration" : {
879
897
"load" : {
0 commit comments