|
42 | 42 | ) |
43 | 43 | from google.cloud.notebooks_v1beta1.services.notebook_service import pagers |
44 | 44 | from google.cloud.notebooks_v1beta1.services.notebook_service import transports |
45 | | -from google.cloud.notebooks_v1beta1.services.notebook_service.transports.base import ( |
46 | | - _API_CORE_VERSION, |
47 | | -) |
48 | 45 | from google.cloud.notebooks_v1beta1.services.notebook_service.transports.base import ( |
49 | 46 | _GOOGLE_AUTH_VERSION, |
50 | 47 | ) |
|
57 | 54 | import google.auth |
58 | 55 |
|
59 | 56 |
|
60 | | -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
61 | | -# - Delete all the api-core and auth "less than" test cases |
| 57 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 58 | +# through google-api-core: |
| 59 | +# - Delete the auth "less than" test cases |
62 | 60 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default). |
63 | 61 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif( |
64 | 62 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), |
|
69 | 67 | reason="This test requires google-auth >= 1.25.0", |
70 | 68 | ) |
71 | 69 |
|
72 | | -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
73 | | - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
74 | | - reason="This test requires google-api-core < 1.26.0", |
75 | | -) |
76 | | - |
77 | | -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
78 | | - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
79 | | - reason="This test requires google-api-core >= 1.26.0", |
80 | | -) |
81 | | - |
82 | 70 |
|
83 | 71 | def client_cert_source_callback(): |
84 | 72 | return b"cert bytes", b"key bytes" |
@@ -141,6 +129,18 @@ def test_notebook_service_client_from_service_account_info(client_class): |
141 | 129 | assert client.transport._host == "notebooks.googleapis.com:443" |
142 | 130 |
|
143 | 131 |
|
| 132 | +@pytest.mark.parametrize( |
| 133 | + "client_class", [NotebookServiceClient, NotebookServiceAsyncClient,] |
| 134 | +) |
| 135 | +def test_notebook_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", [NotebookServiceClient, NotebookServiceAsyncClient,] |
146 | 146 | ) |
@@ -3780,7 +3780,6 @@ def test_notebook_service_transport_auth_adc_old_google_auth(transport_class): |
3780 | 3780 | (transports.NotebookServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3781 | 3781 | ], |
3782 | 3782 | ) |
3783 | | -@requires_api_core_gte_1_26_0 |
3784 | 3783 | def test_notebook_service_transport_create_channel(transport_class, grpc_helpers): |
3785 | 3784 | # If credentials and host are not provided, the transport class should use |
3786 | 3785 | # ADC credentials. |
@@ -3809,79 +3808,6 @@ def test_notebook_service_transport_create_channel(transport_class, grpc_helpers |
3809 | 3808 | ) |
3810 | 3809 |
|
3811 | 3810 |
|
3812 | | -@pytest.mark.parametrize( |
3813 | | - "transport_class,grpc_helpers", |
3814 | | - [ |
3815 | | - (transports.NotebookServiceGrpcTransport, grpc_helpers), |
3816 | | - (transports.NotebookServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3817 | | - ], |
3818 | | -) |
3819 | | -@requires_api_core_lt_1_26_0 |
3820 | | -def test_notebook_service_transport_create_channel_old_api_core( |
3821 | | - transport_class, grpc_helpers |
3822 | | -): |
3823 | | - # If credentials and host are not provided, the transport class should use |
3824 | | - # ADC credentials. |
3825 | | - with mock.patch.object( |
3826 | | - google.auth, "default", autospec=True |
3827 | | - ) as adc, mock.patch.object( |
3828 | | - grpc_helpers, "create_channel", autospec=True |
3829 | | - ) as create_channel: |
3830 | | - creds = ga_credentials.AnonymousCredentials() |
3831 | | - adc.return_value = (creds, None) |
3832 | | - transport_class(quota_project_id="octopus") |
3833 | | - |
3834 | | - create_channel.assert_called_with( |
3835 | | - "notebooks.googleapis.com:443", |
3836 | | - credentials=creds, |
3837 | | - credentials_file=None, |
3838 | | - quota_project_id="octopus", |
3839 | | - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
3840 | | - ssl_credentials=None, |
3841 | | - options=[ |
3842 | | - ("grpc.max_send_message_length", -1), |
3843 | | - ("grpc.max_receive_message_length", -1), |
3844 | | - ], |
3845 | | - ) |
3846 | | - |
3847 | | - |
3848 | | -@pytest.mark.parametrize( |
3849 | | - "transport_class,grpc_helpers", |
3850 | | - [ |
3851 | | - (transports.NotebookServiceGrpcTransport, grpc_helpers), |
3852 | | - (transports.NotebookServiceGrpcAsyncIOTransport, grpc_helpers_async), |
3853 | | - ], |
3854 | | -) |
3855 | | -@requires_api_core_lt_1_26_0 |
3856 | | -def test_notebook_service_transport_create_channel_user_scopes( |
3857 | | - transport_class, grpc_helpers |
3858 | | -): |
3859 | | - # If credentials and host are not provided, the transport class should use |
3860 | | - # ADC credentials. |
3861 | | - with mock.patch.object( |
3862 | | - google.auth, "default", autospec=True |
3863 | | - ) as adc, mock.patch.object( |
3864 | | - grpc_helpers, "create_channel", autospec=True |
3865 | | - ) as create_channel: |
3866 | | - creds = ga_credentials.AnonymousCredentials() |
3867 | | - adc.return_value = (creds, None) |
3868 | | - |
3869 | | - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
3870 | | - |
3871 | | - create_channel.assert_called_with( |
3872 | | - "notebooks.googleapis.com:443", |
3873 | | - credentials=creds, |
3874 | | - credentials_file=None, |
3875 | | - quota_project_id="octopus", |
3876 | | - scopes=["1", "2"], |
3877 | | - ssl_credentials=None, |
3878 | | - options=[ |
3879 | | - ("grpc.max_send_message_length", -1), |
3880 | | - ("grpc.max_receive_message_length", -1), |
3881 | | - ], |
3882 | | - ) |
3883 | | - |
3884 | | - |
3885 | 3811 | @pytest.mark.parametrize( |
3886 | 3812 | "transport_class", |
3887 | 3813 | [ |
|
0 commit comments