|
39 | 39 | ) |
40 | 40 | from google.cloud.bigquery_connection_v1.services.connection_service import pagers |
41 | 41 | from google.cloud.bigquery_connection_v1.services.connection_service import transports |
42 | | -from google.cloud.bigquery_connection_v1.services.connection_service.transports.base import ( |
43 | | - _API_CORE_VERSION, |
44 | | -) |
45 | 42 | from google.cloud.bigquery_connection_v1.services.connection_service.transports.base import ( |
46 | 43 | _GOOGLE_AUTH_VERSION, |
47 | 44 | ) |
|
56 | 53 | import google.auth |
57 | 54 |
|
58 | 55 |
|
59 | | -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
60 | | -# - Delete all the api-core and auth "less than" test cases |
| 56 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 57 | +# through google-api-core: |
| 58 | +# - Delete the auth "less than" test cases |
61 | 59 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default). |
62 | 60 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif( |
63 | 61 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), |
|
68 | 66 | reason="This test requires google-auth >= 1.25.0", |
69 | 67 | ) |
70 | 68 |
|
71 | | -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
72 | | - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
73 | | - reason="This test requires google-api-core < 1.26.0", |
74 | | -) |
75 | | - |
76 | | -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
77 | | - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
78 | | - reason="This test requires google-api-core >= 1.26.0", |
79 | | -) |
80 | | - |
81 | 69 |
|
82 | 70 | def client_cert_source_callback(): |
83 | 71 | return b"cert bytes", b"key bytes" |
@@ -141,6 +129,18 @@ def test_connection_service_client_from_service_account_info(client_class): |
141 | 129 | assert client.transport._host == "bigqueryconnection.googleapis.com:443" |
142 | 130 |
|
143 | 131 |
|
| 132 | +@pytest.mark.parametrize( |
| 133 | + "client_class", [ConnectionServiceClient, ConnectionServiceAsyncClient,] |
| 134 | +) |
| 135 | +def test_connection_service_client_service_account_always_use_jwt(client_class): |
| 136 | + with mock.patch.object( |
| 137 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 138 | + ) as use_jwt: |
| 139 | + creds = service_account.Credentials(None, None, None) |
| 140 | + client = client_class(credentials=creds) |
| 141 | + use_jwt.assert_called_with(True) |
| 142 | + |
| 143 | + |
144 | 144 | @pytest.mark.parametrize( |
145 | 145 | "client_class", [ConnectionServiceClient, ConnectionServiceAsyncClient,] |
146 | 146 | ) |
@@ -2729,7 +2729,6 @@ def test_connection_service_transport_auth_adc_old_google_auth(transport_class): |
2729 | 2729 | (transports.ConnectionServiceGrpcAsyncIOTransport, grpc_helpers_async), |
2730 | 2730 | ], |
2731 | 2731 | ) |
2732 | | -@requires_api_core_gte_1_26_0 |
2733 | 2732 | def test_connection_service_transport_create_channel(transport_class, grpc_helpers): |
2734 | 2733 | # If credentials and host are not provided, the transport class should use |
2735 | 2734 | # ADC credentials. |
@@ -2761,82 +2760,6 @@ def test_connection_service_transport_create_channel(transport_class, grpc_helpe |
2761 | 2760 | ) |
2762 | 2761 |
|
2763 | 2762 |
|
2764 | | -@pytest.mark.parametrize( |
2765 | | - "transport_class,grpc_helpers", |
2766 | | - [ |
2767 | | - (transports.ConnectionServiceGrpcTransport, grpc_helpers), |
2768 | | - (transports.ConnectionServiceGrpcAsyncIOTransport, grpc_helpers_async), |
2769 | | - ], |
2770 | | -) |
2771 | | -@requires_api_core_lt_1_26_0 |
2772 | | -def test_connection_service_transport_create_channel_old_api_core( |
2773 | | - transport_class, grpc_helpers |
2774 | | -): |
2775 | | - # If credentials and host are not provided, the transport class should use |
2776 | | - # ADC credentials. |
2777 | | - with mock.patch.object( |
2778 | | - google.auth, "default", autospec=True |
2779 | | - ) as adc, mock.patch.object( |
2780 | | - grpc_helpers, "create_channel", autospec=True |
2781 | | - ) as create_channel: |
2782 | | - creds = ga_credentials.AnonymousCredentials() |
2783 | | - adc.return_value = (creds, None) |
2784 | | - transport_class(quota_project_id="octopus") |
2785 | | - |
2786 | | - create_channel.assert_called_with( |
2787 | | - "bigqueryconnection.googleapis.com:443", |
2788 | | - credentials=creds, |
2789 | | - credentials_file=None, |
2790 | | - quota_project_id="octopus", |
2791 | | - scopes=( |
2792 | | - "https://www.googleapis.com/auth/bigquery", |
2793 | | - "https://www.googleapis.com/auth/cloud-platform", |
2794 | | - ), |
2795 | | - ssl_credentials=None, |
2796 | | - options=[ |
2797 | | - ("grpc.max_send_message_length", -1), |
2798 | | - ("grpc.max_receive_message_length", -1), |
2799 | | - ], |
2800 | | - ) |
2801 | | - |
2802 | | - |
2803 | | -@pytest.mark.parametrize( |
2804 | | - "transport_class,grpc_helpers", |
2805 | | - [ |
2806 | | - (transports.ConnectionServiceGrpcTransport, grpc_helpers), |
2807 | | - (transports.ConnectionServiceGrpcAsyncIOTransport, grpc_helpers_async), |
2808 | | - ], |
2809 | | -) |
2810 | | -@requires_api_core_lt_1_26_0 |
2811 | | -def test_connection_service_transport_create_channel_user_scopes( |
2812 | | - transport_class, grpc_helpers |
2813 | | -): |
2814 | | - # If credentials and host are not provided, the transport class should use |
2815 | | - # ADC credentials. |
2816 | | - with mock.patch.object( |
2817 | | - google.auth, "default", autospec=True |
2818 | | - ) as adc, mock.patch.object( |
2819 | | - grpc_helpers, "create_channel", autospec=True |
2820 | | - ) as create_channel: |
2821 | | - creds = ga_credentials.AnonymousCredentials() |
2822 | | - adc.return_value = (creds, None) |
2823 | | - |
2824 | | - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
2825 | | - |
2826 | | - create_channel.assert_called_with( |
2827 | | - "bigqueryconnection.googleapis.com:443", |
2828 | | - credentials=creds, |
2829 | | - credentials_file=None, |
2830 | | - quota_project_id="octopus", |
2831 | | - scopes=["1", "2"], |
2832 | | - ssl_credentials=None, |
2833 | | - options=[ |
2834 | | - ("grpc.max_send_message_length", -1), |
2835 | | - ("grpc.max_receive_message_length", -1), |
2836 | | - ], |
2837 | | - ) |
2838 | | - |
2839 | | - |
2840 | 2763 | @pytest.mark.parametrize( |
2841 | 2764 | "transport_class", |
2842 | 2765 | [ |
|
0 commit comments