@@ -425,9 +425,14 @@ def test_list_projects_defaults(self):
425
425
creds = _make_credentials ()
426
426
client = self ._make_one (PROJECT_1 , creds )
427
427
conn = client ._connection = make_connection (DATA )
428
-
429
428
iterator = client .list_projects ()
430
- page = six .next (iterator .pages )
429
+
430
+ with mock .patch (
431
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
432
+ ) as final_attributes :
433
+ page = six .next (iterator .pages )
434
+
435
+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
431
436
projects = list (page )
432
437
token = iterator .next_page_token
433
438
@@ -455,7 +460,13 @@ def test_list_projects_w_timeout(self):
455
460
conn = client ._connection = make_connection (DATA )
456
461
457
462
iterator = client .list_projects (timeout = 7.5 )
458
- six .next (iterator .pages )
463
+
464
+ with mock .patch (
465
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
466
+ ) as final_attributes :
467
+ six .next (iterator .pages )
468
+
469
+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
459
470
460
471
conn .api_request .assert_called_once_with (
461
472
method = "GET" , path = "/projects" , query_params = {}, timeout = 7.5
@@ -469,7 +480,13 @@ def test_list_projects_explicit_response_missing_projects_key(self):
469
480
conn = client ._connection = make_connection (DATA )
470
481
471
482
iterator = client .list_projects (max_results = 3 , page_token = TOKEN )
472
- page = six .next (iterator .pages )
483
+
484
+ with mock .patch (
485
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
486
+ ) as final_attributes :
487
+ page = six .next (iterator .pages )
488
+
489
+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
473
490
projects = list (page )
474
491
token = iterator .next_page_token
475
492
@@ -518,7 +535,12 @@ def test_list_datasets_defaults(self):
518
535
conn = client ._connection = make_connection (DATA )
519
536
520
537
iterator = client .list_datasets ()
521
- page = six .next (iterator .pages )
538
+ with mock .patch (
539
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
540
+ ) as final_attributes :
541
+ page = six .next (iterator .pages )
542
+
543
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
522
544
datasets = list (page )
523
545
token = iterator .next_page_token
524
546
@@ -538,7 +560,14 @@ def test_list_datasets_w_project_and_timeout(self):
538
560
client = self ._make_one (self .PROJECT , creds )
539
561
conn = client ._connection = make_connection ({})
540
562
541
- list (client .list_datasets (project = "other-project" , timeout = 7.5 ))
563
+ with mock .patch (
564
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
565
+ ) as final_attributes :
566
+ list (client .list_datasets (project = "other-project" , timeout = 7.5 ))
567
+
568
+ final_attributes .assert_called_once_with (
569
+ {"path" : "/projects/other-project/datasets" }, client , None
570
+ )
542
571
543
572
conn .api_request .assert_called_once_with (
544
573
method = "GET" ,
@@ -559,7 +588,12 @@ def test_list_datasets_explicit_response_missing_datasets_key(self):
559
588
iterator = client .list_datasets (
560
589
include_all = True , filter = FILTER , max_results = 3 , page_token = TOKEN
561
590
)
562
- page = six .next (iterator .pages )
591
+ with mock .patch (
592
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
593
+ ) as final_attributes :
594
+ page = six .next (iterator .pages )
595
+
596
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
563
597
datasets = list (page )
564
598
token = iterator .next_page_token
565
599
@@ -2838,7 +2872,12 @@ def test_list_tables_empty_w_timeout(self):
2838
2872
dataset = DatasetReference (self .PROJECT , self .DS_ID )
2839
2873
iterator = client .list_tables (dataset , timeout = 7.5 )
2840
2874
self .assertIs (iterator .dataset , dataset )
2841
- page = six .next (iterator .pages )
2875
+ with mock .patch (
2876
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2877
+ ) as final_attributes :
2878
+ page = six .next (iterator .pages )
2879
+
2880
+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
2842
2881
tables = list (page )
2843
2882
token = iterator .next_page_token
2844
2883
@@ -2856,7 +2895,12 @@ def test_list_models_empty_w_timeout(self):
2856
2895
2857
2896
dataset_id = "{}.{}" .format (self .PROJECT , self .DS_ID )
2858
2897
iterator = client .list_models (dataset_id , timeout = 7.5 )
2859
- page = six .next (iterator .pages )
2898
+ with mock .patch (
2899
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2900
+ ) as final_attributes :
2901
+ page = six .next (iterator .pages )
2902
+
2903
+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
2860
2904
models = list (page )
2861
2905
token = iterator .next_page_token
2862
2906
@@ -2900,7 +2944,12 @@ def test_list_models_defaults(self):
2900
2944
2901
2945
iterator = client .list_models (dataset )
2902
2946
self .assertIs (iterator .dataset , dataset )
2903
- page = six .next (iterator .pages )
2947
+ with mock .patch (
2948
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2949
+ ) as final_attributes :
2950
+ page = six .next (iterator .pages )
2951
+
2952
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
2904
2953
models = list (page )
2905
2954
token = iterator .next_page_token
2906
2955
@@ -2926,7 +2975,16 @@ def test_list_routines_empty_w_timeout(self):
2926
2975
conn = client ._connection = make_connection ({})
2927
2976
2928
2977
iterator = client .list_routines ("test-routines.test_routines" , timeout = 7.5 )
2929
- page = six .next (iterator .pages )
2978
+ with mock .patch (
2979
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2980
+ ) as final_attributes :
2981
+ page = six .next (iterator .pages )
2982
+
2983
+ final_attributes .assert_called_once_with (
2984
+ {"path" : "/projects/test-routines/datasets/test_routines/routines" },
2985
+ client ,
2986
+ None ,
2987
+ )
2930
2988
routines = list (page )
2931
2989
token = iterator .next_page_token
2932
2990
@@ -2975,7 +3033,12 @@ def test_list_routines_defaults(self):
2975
3033
2976
3034
iterator = client .list_routines (dataset )
2977
3035
self .assertIs (iterator .dataset , dataset )
2978
- page = six .next (iterator .pages )
3036
+ with mock .patch (
3037
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3038
+ ) as final_attributes :
3039
+ page = six .next (iterator .pages )
3040
+
3041
+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
2979
3042
routines = list (page )
2980
3043
actual_token = iterator .next_page_token
2981
3044
@@ -3039,7 +3102,12 @@ def test_list_tables_defaults(self):
3039
3102
3040
3103
iterator = client .list_tables (dataset )
3041
3104
self .assertIs (iterator .dataset , dataset )
3042
- page = six .next (iterator .pages )
3105
+ with mock .patch (
3106
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3107
+ ) as final_attributes :
3108
+ page = six .next (iterator .pages )
3109
+
3110
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
3043
3111
tables = list (page )
3044
3112
token = iterator .next_page_token
3045
3113
@@ -3098,7 +3166,12 @@ def test_list_tables_explicit(self):
3098
3166
page_token = TOKEN ,
3099
3167
)
3100
3168
self .assertEqual (iterator .dataset , dataset )
3101
- page = six .next (iterator .pages )
3169
+ with mock .patch (
3170
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3171
+ ) as final_attributes :
3172
+ page = six .next (iterator .pages )
3173
+
3174
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
3102
3175
tables = list (page )
3103
3176
token = iterator .next_page_token
3104
3177
@@ -3921,7 +3994,12 @@ def test_list_jobs_defaults(self):
3921
3994
conn = client ._connection = make_connection (DATA )
3922
3995
3923
3996
iterator = client .list_jobs ()
3924
- page = six .next (iterator .pages )
3997
+ with mock .patch (
3998
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3999
+ ) as final_attributes :
4000
+ page = six .next (iterator .pages )
4001
+
4002
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
3925
4003
jobs = list (page )
3926
4004
token = iterator .next_page_token
3927
4005
@@ -3966,7 +4044,12 @@ def test_list_jobs_load_job_wo_sourceUris(self):
3966
4044
conn = client ._connection = make_connection (DATA )
3967
4045
3968
4046
iterator = client .list_jobs ()
3969
- page = six .next (iterator .pages )
4047
+ with mock .patch (
4048
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
4049
+ ) as final_attributes :
4050
+ page = six .next (iterator .pages )
4051
+
4052
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
3970
4053
jobs = list (page )
3971
4054
token = iterator .next_page_token
3972
4055
@@ -3995,7 +4078,12 @@ def test_list_jobs_explicit_missing(self):
3995
4078
iterator = client .list_jobs (
3996
4079
max_results = 1000 , page_token = TOKEN , all_users = True , state_filter = "done"
3997
4080
)
3998
- page = six .next (iterator .pages )
4081
+ with mock .patch (
4082
+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
4083
+ ) as final_attributes :
4084
+ page = six .next (iterator .pages )
4085
+
4086
+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
3999
4087
jobs = list (page )
4000
4088
token = iterator .next_page_token
4001
4089
0 commit comments