@@ -3573,21 +3573,28 @@ def test_delete_table_w_not_found_ok_true(self):
3573
3573
3574
3574
conn .api_request .assert_called_with (method = "DELETE" , path = path , timeout = None )
3575
3575
3576
- def _create_job_helper (self , job_config , client_method ):
3576
+ def _create_job_helper (self , job_config ):
3577
+ from google .cloud .bigquery import _helpers
3578
+
3577
3579
creds = _make_credentials ()
3578
3580
http = object ()
3579
3581
client = self ._make_one (project = self .PROJECT , credentials = creds , _http = http )
3580
3582
3581
- client ._connection = make_connection ()
3582
- rf1 = mock .Mock ()
3583
- get_config_patch = mock .patch (
3584
- "google.cloud.bigquery.job._JobConfig.from_api_repr" , return_value = rf1 ,
3585
- )
3586
- load_patch = mock .patch (client_method , autospec = True )
3583
+ RESOURCE = {
3584
+ "jobReference" : {"projectId" : self .PROJECT , "jobId" : mock .ANY },
3585
+ "configuration" : job_config ,
3586
+ }
3587
+ conn = client ._connection = make_connection (RESOURCE )
3588
+ client .create_job (job_config = job_config )
3589
+ if "query" in job_config :
3590
+ _helpers ._del_sub_prop (job_config , ["query" , "destinationTable" ])
3587
3591
3588
- with load_patch as client_method , get_config_patch :
3589
- client .create_job (job_config = job_config )
3590
- client_method .assert_called_once ()
3592
+ conn .api_request .assert_called_once_with (
3593
+ method = "POST" ,
3594
+ path = "/projects/%s/jobs" % self .PROJECT ,
3595
+ data = RESOURCE ,
3596
+ timeout = None ,
3597
+ )
3591
3598
3592
3599
def test_create_job_load_config (self ):
3593
3600
configuration = {
@@ -3601,9 +3608,7 @@ def test_create_job_load_config(self):
3601
3608
}
3602
3609
}
3603
3610
3604
- self ._create_job_helper (
3605
- configuration , "google.cloud.bigquery.client.Client.load_table_from_uri"
3606
- )
3611
+ self ._create_job_helper (configuration )
3607
3612
3608
3613
def test_create_job_copy_config (self ):
3609
3614
configuration = {
@@ -3623,9 +3628,7 @@ def test_create_job_copy_config(self):
3623
3628
}
3624
3629
}
3625
3630
3626
- self ._create_job_helper (
3627
- configuration , "google.cloud.bigquery.client.Client.copy_table" ,
3628
- )
3631
+ self ._create_job_helper (configuration )
3629
3632
3630
3633
def test_create_job_copy_config_w_single_source (self ):
3631
3634
configuration = {
@@ -3643,9 +3646,7 @@ def test_create_job_copy_config_w_single_source(self):
3643
3646
}
3644
3647
}
3645
3648
3646
- self ._create_job_helper (
3647
- configuration , "google.cloud.bigquery.client.Client.copy_table" ,
3648
- )
3649
+ self ._create_job_helper (configuration )
3649
3650
3650
3651
def test_create_job_extract_config (self ):
3651
3652
configuration = {
@@ -3658,9 +3659,7 @@ def test_create_job_extract_config(self):
3658
3659
"destinationUris" : ["gs://test_bucket/dst_object*" ],
3659
3660
}
3660
3661
}
3661
- self ._create_job_helper (
3662
- configuration , "google.cloud.bigquery.client.Client.extract_table" ,
3663
- )
3662
+ self ._create_job_helper (configuration )
3664
3663
3665
3664
def test_create_job_extract_config_for_model (self ):
3666
3665
configuration = {
@@ -3673,17 +3672,17 @@ def test_create_job_extract_config_for_model(self):
3673
3672
"destinationUris" : ["gs://test_bucket/dst_object*" ],
3674
3673
}
3675
3674
}
3676
- self ._create_job_helper (
3677
- configuration , "google.cloud.bigquery.client.Client.extract_table" ,
3678
- )
3675
+ self ._create_job_helper (configuration )
3679
3676
3680
3677
def test_create_job_query_config (self ):
3681
3678
configuration = {
3682
- "query" : {"query" : "query" , "destinationTable" : {"tableId" : "table_id" }}
3679
+ "query" : {
3680
+ "query" : "query" ,
3681
+ "destinationTable" : {"tableId" : "table_id" },
3682
+ "useLegacySql" : False ,
3683
+ }
3683
3684
}
3684
- self ._create_job_helper (
3685
- configuration , "google.cloud.bigquery.client.Client.query" ,
3686
- )
3685
+ self ._create_job_helper (configuration )
3687
3686
3688
3687
def test_create_job_query_config_w_rateLimitExceeded_error (self ):
3689
3688
from google .cloud .exceptions import Forbidden
0 commit comments