|
22 | 22 | from google.api_core import exceptions |
23 | 23 | from google.api_core import gapic_v1 |
24 | 24 | from google.api_core import retry as retries |
| 25 | +from google.auth.credentials import AnonymousCredentials |
25 | 26 | from google.cloud.bigtable_admin_v2.services.bigtable_table_admin import transports |
26 | 27 | from google.cloud.bigtable_admin_v2.types import bigtable_table_admin |
27 | 28 | from google.cloud.bigtable_admin_v2.overlay.services.bigtable_table_admin.client import ( |
|
48 | 49 | CONSISTENCY_TOKEN = "abcdefg" |
49 | 50 |
|
50 | 51 |
|
| 52 | +def _make_client(**kwargs): |
| 53 | + kwargs["credentials"] = kwargs.get("credentials", AnonymousCredentials()) |
| 54 | + return BigtableTableAdminClient(**kwargs) |
| 55 | + |
| 56 | + |
51 | 57 | @pytest.mark.parametrize( |
52 | 58 | "transport_class,transport_name", |
53 | 59 | [ |
|
64 | 70 | def test_bigtable_table_admin_client_client_version(transport_class, transport_name): |
65 | 71 | with mock.patch.object(transport_class, "__init__") as patched: |
66 | 72 | patched.return_value = None |
67 | | - BigtableTableAdminClient(transport=transport_name) |
| 73 | + _make_client(transport=transport_name) |
68 | 74 |
|
69 | 75 | # call_args.kwargs is not supported in Python 3.7, so find them from the tuple |
70 | 76 | # instead. It's always the last item in the call_args tuple. |
@@ -104,7 +110,7 @@ def test_bigtable_table_admin_client_client_version(transport_class, transport_n |
104 | 110 | ], |
105 | 111 | ) |
106 | 112 | def test_bigtable_table_admin_client_restore_table(kwargs): |
107 | | - client = BigtableTableAdminClient() |
| 113 | + client = _make_client() |
108 | 114 |
|
109 | 115 | with mock.patch.object(restore_table, "RestoreTableOperation") as future_mock: |
110 | 116 | with mock.patch.object(client, "_transport") as transport_mock: |
@@ -190,7 +196,7 @@ def test_bigtable_table_admin_client_restore_table(kwargs): |
190 | 196 | def test_bigtable_table_admin_client_wait_for_consistency( |
191 | 197 | kwargs, check_consistency_request_extras |
192 | 198 | ): |
193 | | - client = BigtableTableAdminClient() |
| 199 | + client = _make_client() |
194 | 200 | poll_count = 3 |
195 | 201 | check_mock_side_effect = [FALSE_CONSISTENCY_RESPONSE] * (poll_count - 1) |
196 | 202 | check_mock_side_effect.append(TRUE_CONSISTENCY_RESPONSE) |
@@ -234,7 +240,7 @@ def test_bigtable_table_admin_client_wait_for_consistency( |
234 | 240 |
|
235 | 241 |
|
236 | 242 | def test_bigtable_table_admin_client_wait_for_consistency_error_in_call(): |
237 | | - client = BigtableTableAdminClient() |
| 243 | + client = _make_client() |
238 | 244 | request = wait_for_consistency_request.WaitForConsistencyRequest( |
239 | 245 | name=TABLE_NAME, |
240 | 246 | ) |
@@ -262,7 +268,7 @@ def test_bigtable_table_admin_client_wait_for_consistency_error_in_call(): |
262 | 268 |
|
263 | 269 |
|
264 | 270 | def test_bigtable_table_admin_client_wait_for_consistency_user_error(): |
265 | | - client = BigtableTableAdminClient() |
| 271 | + client = _make_client() |
266 | 272 | with pytest.raises(ValueError): |
267 | 273 | client.wait_for_consistency( |
268 | 274 | { |
|
0 commit comments