|
29 | 29 | from google.api_core import gapic_v1
|
30 | 30 | from google.api_core import grpc_helpers
|
31 | 31 | from google.api_core import grpc_helpers_async
|
| 32 | +from google.api_core import operation |
32 | 33 | from google.api_core import operation_async # type: ignore
|
33 | 34 | from google.api_core import operations_v1
|
34 | 35 | from google.api_core import path_template
|
@@ -525,21 +526,28 @@ def test_cloud_shell_service_client_client_options_scopes(
|
525 | 526 |
|
526 | 527 |
|
527 | 528 | @pytest.mark.parametrize(
|
528 |
| - "client_class,transport_class,transport_name", |
| 529 | + "client_class,transport_class,transport_name,grpc_helpers", |
529 | 530 | [
|
530 |
| - (CloudShellServiceClient, transports.CloudShellServiceGrpcTransport, "grpc"), |
| 531 | + ( |
| 532 | + CloudShellServiceClient, |
| 533 | + transports.CloudShellServiceGrpcTransport, |
| 534 | + "grpc", |
| 535 | + grpc_helpers, |
| 536 | + ), |
531 | 537 | (
|
532 | 538 | CloudShellServiceAsyncClient,
|
533 | 539 | transports.CloudShellServiceGrpcAsyncIOTransport,
|
534 | 540 | "grpc_asyncio",
|
| 541 | + grpc_helpers_async, |
535 | 542 | ),
|
536 | 543 | ],
|
537 | 544 | )
|
538 | 545 | def test_cloud_shell_service_client_client_options_credentials_file(
|
539 |
| - client_class, transport_class, transport_name |
| 546 | + client_class, transport_class, transport_name, grpc_helpers |
540 | 547 | ):
|
541 | 548 | # Check the case credentials file is provided.
|
542 | 549 | options = client_options.ClientOptions(credentials_file="credentials.json")
|
| 550 | + |
543 | 551 | with mock.patch.object(transport_class, "__init__") as patched:
|
544 | 552 | patched.return_value = None
|
545 | 553 | client = client_class(client_options=options, transport=transport_name)
|
@@ -575,6 +583,72 @@ def test_cloud_shell_service_client_client_options_from_dict():
|
575 | 583 | )
|
576 | 584 |
|
577 | 585 |
|
| 586 | +@pytest.mark.parametrize( |
| 587 | + "client_class,transport_class,transport_name,grpc_helpers", |
| 588 | + [ |
| 589 | + ( |
| 590 | + CloudShellServiceClient, |
| 591 | + transports.CloudShellServiceGrpcTransport, |
| 592 | + "grpc", |
| 593 | + grpc_helpers, |
| 594 | + ), |
| 595 | + ( |
| 596 | + CloudShellServiceAsyncClient, |
| 597 | + transports.CloudShellServiceGrpcAsyncIOTransport, |
| 598 | + "grpc_asyncio", |
| 599 | + grpc_helpers_async, |
| 600 | + ), |
| 601 | + ], |
| 602 | +) |
| 603 | +def test_cloud_shell_service_client_create_channel_credentials_file( |
| 604 | + client_class, transport_class, transport_name, grpc_helpers |
| 605 | +): |
| 606 | + # Check the case credentials file is provided. |
| 607 | + options = client_options.ClientOptions(credentials_file="credentials.json") |
| 608 | + |
| 609 | + with mock.patch.object(transport_class, "__init__") as patched: |
| 610 | + patched.return_value = None |
| 611 | + client = client_class(client_options=options, transport=transport_name) |
| 612 | + patched.assert_called_once_with( |
| 613 | + credentials=None, |
| 614 | + credentials_file="credentials.json", |
| 615 | + host=client.DEFAULT_ENDPOINT, |
| 616 | + scopes=None, |
| 617 | + client_cert_source_for_mtls=None, |
| 618 | + quota_project_id=None, |
| 619 | + client_info=transports.base.DEFAULT_CLIENT_INFO, |
| 620 | + always_use_jwt_access=True, |
| 621 | + ) |
| 622 | + |
| 623 | + # test that the credentials from file are saved and used as the credentials. |
| 624 | + with mock.patch.object( |
| 625 | + google.auth, "load_credentials_from_file", autospec=True |
| 626 | + ) as load_creds, mock.patch.object( |
| 627 | + google.auth, "default", autospec=True |
| 628 | + ) as adc, mock.patch.object( |
| 629 | + grpc_helpers, "create_channel" |
| 630 | + ) as create_channel: |
| 631 | + creds = ga_credentials.AnonymousCredentials() |
| 632 | + file_creds = ga_credentials.AnonymousCredentials() |
| 633 | + load_creds.return_value = (file_creds, None) |
| 634 | + adc.return_value = (creds, None) |
| 635 | + client = client_class(client_options=options, transport=transport_name) |
| 636 | + create_channel.assert_called_with( |
| 637 | + "cloudshell.googleapis.com:443", |
| 638 | + credentials=file_creds, |
| 639 | + credentials_file=None, |
| 640 | + quota_project_id=None, |
| 641 | + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), |
| 642 | + scopes=None, |
| 643 | + default_host="cloudshell.googleapis.com", |
| 644 | + ssl_credentials=None, |
| 645 | + options=[ |
| 646 | + ("grpc.max_send_message_length", -1), |
| 647 | + ("grpc.max_receive_message_length", -1), |
| 648 | + ], |
| 649 | + ) |
| 650 | + |
| 651 | + |
578 | 652 | @pytest.mark.parametrize("request_type", [cloudshell.GetEnvironmentRequest, dict,])
|
579 | 653 | def test_get_environment(request_type, transport: str = "grpc"):
|
580 | 654 | client = CloudShellServiceClient(
|
|
0 commit comments