|
35 | 35 | from google.area120.tables_v1alpha1.services.tables_service import TablesServiceClient |
36 | 36 | from google.area120.tables_v1alpha1.services.tables_service import pagers |
37 | 37 | from google.area120.tables_v1alpha1.services.tables_service import transports |
38 | | -from google.area120.tables_v1alpha1.services.tables_service.transports.base import ( |
39 | | - _API_CORE_VERSION, |
40 | | -) |
41 | 38 | from google.area120.tables_v1alpha1.services.tables_service.transports.base import ( |
42 | 39 | _GOOGLE_AUTH_VERSION, |
43 | 40 | ) |
|
50 | 47 | import google.auth |
51 | 48 |
|
52 | 49 |
|
53 | | -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
54 | | -# - Delete all the api-core and auth "less than" test cases |
| 50 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 51 | +# through google-api-core: |
| 52 | +# - Delete the auth "less than" test cases |
55 | 53 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default). |
56 | 54 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif( |
57 | 55 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), |
|
62 | 60 | reason="This test requires google-auth >= 1.25.0", |
63 | 61 | ) |
64 | 62 |
|
65 | | -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
66 | | - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
67 | | - reason="This test requires google-api-core < 1.26.0", |
68 | | -) |
69 | | - |
70 | | -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
71 | | - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
72 | | - reason="This test requires google-api-core >= 1.26.0", |
73 | | -) |
74 | | - |
75 | 63 |
|
76 | 64 | def client_cert_source_callback(): |
77 | 65 | return b"cert bytes", b"key bytes" |
@@ -134,6 +122,18 @@ def test_tables_service_client_from_service_account_info(client_class): |
134 | 122 | assert client.transport._host == "area120tables.googleapis.com:443" |
135 | 123 |
|
136 | 124 |
|
| 125 | +@pytest.mark.parametrize( |
| 126 | + "client_class", [TablesServiceClient, TablesServiceAsyncClient,] |
| 127 | +) |
| 128 | +def test_tables_service_client_service_account_always_use_jwt(client_class): |
| 129 | + with mock.patch.object( |
| 130 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 131 | + ) as use_jwt: |
| 132 | + creds = service_account.Credentials(None, None, None) |
| 133 | + client = client_class(credentials=creds) |
| 134 | + use_jwt.assert_called_with(True) |
| 135 | + |
| 136 | + |
137 | 137 | @pytest.mark.parametrize( |
138 | 138 | "client_class", [TablesServiceClient, TablesServiceAsyncClient,] |
139 | 139 | ) |
@@ -3089,7 +3089,6 @@ def test_tables_service_transport_auth_adc_old_google_auth(transport_class): |
3089 | 3089 | (transports.TablesServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3090 | 3090 | ], |
3091 | 3091 | ) |
3092 | | -@requires_api_core_gte_1_26_0 |
3093 | 3092 | def test_tables_service_transport_create_channel(transport_class, grpc_helpers): |
3094 | 3093 | # If credentials and host are not provided, the transport class should use |
3095 | 3094 | # ADC credentials. |
@@ -3125,86 +3124,6 @@ def test_tables_service_transport_create_channel(transport_class, grpc_helpers): |
3125 | 3124 | ) |
3126 | 3125 |
|
3127 | 3126 |
|
3128 | | -@pytest.mark.parametrize( |
3129 | | - "transport_class,grpc_helpers", |
3130 | | - [ |
3131 | | - (transports.TablesServiceGrpcTransport, grpc_helpers), |
3132 | | - (transports.TablesServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3133 | | - ], |
3134 | | -) |
3135 | | -@requires_api_core_lt_1_26_0 |
3136 | | -def test_tables_service_transport_create_channel_old_api_core( |
3137 | | - transport_class, grpc_helpers |
3138 | | -): |
3139 | | - # If credentials and host are not provided, the transport class should use |
3140 | | - # ADC credentials. |
3141 | | - with mock.patch.object( |
3142 | | - google.auth, "default", autospec=True |
3143 | | - ) as adc, mock.patch.object( |
3144 | | - grpc_helpers, "create_channel", autospec=True |
3145 | | - ) as create_channel: |
3146 | | - creds = ga_credentials.AnonymousCredentials() |
3147 | | - adc.return_value = (creds, None) |
3148 | | - transport_class(quota_project_id="octopus") |
3149 | | - |
3150 | | - create_channel.assert_called_with( |
3151 | | - "area120tables.googleapis.com:443", |
3152 | | - credentials=creds, |
3153 | | - credentials_file=None, |
3154 | | - quota_project_id="octopus", |
3155 | | - scopes=( |
3156 | | - "https://www.googleapis.com/auth/drive", |
3157 | | - "https://www.googleapis.com/auth/drive.file", |
3158 | | - "https://www.googleapis.com/auth/drive.readonly", |
3159 | | - "https://www.googleapis.com/auth/spreadsheets", |
3160 | | - "https://www.googleapis.com/auth/spreadsheets.readonly", |
3161 | | - "https://www.googleapis.com/auth/tables", |
3162 | | - ), |
3163 | | - ssl_credentials=None, |
3164 | | - options=[ |
3165 | | - ("grpc.max_send_message_length", -1), |
3166 | | - ("grpc.max_receive_message_length", -1), |
3167 | | - ], |
3168 | | - ) |
3169 | | - |
3170 | | - |
3171 | | -@pytest.mark.parametrize( |
3172 | | - "transport_class,grpc_helpers", |
3173 | | - [ |
3174 | | - (transports.TablesServiceGrpcTransport, grpc_helpers), |
3175 | | - (transports.TablesServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3176 | | - ], |
3177 | | -) |
3178 | | -@requires_api_core_lt_1_26_0 |
3179 | | -def test_tables_service_transport_create_channel_user_scopes( |
3180 | | - transport_class, grpc_helpers |
3181 | | -): |
3182 | | - # If credentials and host are not provided, the transport class should use |
3183 | | - # ADC credentials. |
3184 | | - with mock.patch.object( |
3185 | | - google.auth, "default", autospec=True |
3186 | | - ) as adc, mock.patch.object( |
3187 | | - grpc_helpers, "create_channel", autospec=True |
3188 | | - ) as create_channel: |
3189 | | - creds = ga_credentials.AnonymousCredentials() |
3190 | | - adc.return_value = (creds, None) |
3191 | | - |
3192 | | - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
3193 | | - |
3194 | | - create_channel.assert_called_with( |
3195 | | - "area120tables.googleapis.com:443", |
3196 | | - credentials=creds, |
3197 | | - credentials_file=None, |
3198 | | - quota_project_id="octopus", |
3199 | | - scopes=["1", "2"], |
3200 | | - ssl_credentials=None, |
3201 | | - options=[ |
3202 | | - ("grpc.max_send_message_length", -1), |
3203 | | - ("grpc.max_receive_message_length", -1), |
3204 | | - ], |
3205 | | - ) |
3206 | | - |
3207 | | - |
3208 | 3127 | @pytest.mark.parametrize( |
3209 | 3128 | "transport_class", |
3210 | 3129 | [ |
|
0 commit comments