Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

chore: use gapic-generator-python 0.58.4 #55

Merged
merged 3 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
71 changes: 25 additions & 46 deletions 71 tests/unit/gapic/service_v1/test_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,20 @@ def test_environments_client_client_options(
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_environments_client_mtls_env_auto(
)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)

if use_client_cert_env == "false":
expected_client_cert_source = None
Expand Down Expand Up @@ -415,7 +415,7 @@ def test_environments_client_client_options_scopes(
options = client_options.ClientOptions(scopes=["1", "2"],)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -446,7 +446,7 @@ def test_environments_client_client_options_credentials_file(
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
Expand Down Expand Up @@ -477,9 +477,8 @@ def test_environments_client_client_options_from_dict():
)


def test_create_environment(
transport: str = "grpc", request_type=environments.CreateEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [environments.CreateEnvironmentRequest, dict,])
def test_create_environment(request_type, transport: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -505,10 +504,6 @@ def test_create_environment(
assert isinstance(response, future.Future)


def test_create_environment_from_dict():
test_create_environment(request_type=dict)


def test_create_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -705,9 +700,8 @@ async def test_create_environment_flattened_error_async():
)


def test_get_environment(
transport: str = "grpc", request_type=environments.GetEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [environments.GetEnvironmentRequest, dict,])
def test_get_environment(request_type, transport: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -738,10 +732,6 @@ def test_get_environment(
assert response.state == environments.Environment.State.CREATING


def test_get_environment_from_dict():
test_get_environment(request_type=dict)


def test_get_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -917,9 +907,8 @@ async def test_get_environment_flattened_error_async():
)


def test_list_environments(
transport: str = "grpc", request_type=environments.ListEnvironmentsRequest
):
@pytest.mark.parametrize("request_type", [environments.ListEnvironmentsRequest, dict,])
def test_list_environments(request_type, transport: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -948,10 +937,6 @@ def test_list_environments(
assert response.next_page_token == "next_page_token_value"


def test_list_environments_from_dict():
test_list_environments(request_type=dict)


def test_list_environments_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1135,8 +1120,10 @@ async def test_list_environments_flattened_error_async():
)


def test_list_environments_pager():
client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_environments_pager(transport_name: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -1177,8 +1164,10 @@ def test_list_environments_pager():
assert all(isinstance(i, environments.Environment) for i in results)


def test_list_environments_pages():
client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_environments_pages(transport_name: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -1289,9 +1278,8 @@ async def test_list_environments_async_pages():
assert page_.raw_page.next_page_token == token


def test_update_environment(
transport: str = "grpc", request_type=environments.UpdateEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [environments.UpdateEnvironmentRequest, dict,])
def test_update_environment(request_type, transport: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -1317,10 +1305,6 @@ def test_update_environment(
assert isinstance(response, future.Future)


def test_update_environment_from_dict():
test_update_environment(request_type=dict)


def test_update_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1527,9 +1511,8 @@ async def test_update_environment_flattened_error_async():
)


def test_delete_environment(
transport: str = "grpc", request_type=environments.DeleteEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [environments.DeleteEnvironmentRequest, dict,])
def test_delete_environment(request_type, transport: str = "grpc"):
client = EnvironmentsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -1555,10 +1538,6 @@ def test_delete_environment(
assert isinstance(response, future.Future)


def test_delete_environment_from_dict():
test_delete_environment(request_type=dict)


def test_delete_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -2277,7 +2256,7 @@ def test_parse_common_location_path():
assert expected == actual


def test_client_withDEFAULT_CLIENT_INFO():
def test_client_with_default_client_info():
client_info = gapic_v1.client_info.ClientInfo()

with mock.patch.object(
Expand Down
37 changes: 19 additions & 18 deletions 37 tests/unit/gapic/service_v1/test_image_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,20 @@ def test_image_versions_client_client_options(
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_image_versions_client_mtls_env_auto(
)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)

if use_client_cert_env == "false":
expected_client_cert_source = None
Expand Down Expand Up @@ -419,7 +419,7 @@ def test_image_versions_client_client_options_scopes(
options = client_options.ClientOptions(scopes=["1", "2"],)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_image_versions_client_client_options_credentials_file(
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
Expand Down Expand Up @@ -483,9 +483,10 @@ def test_image_versions_client_client_options_from_dict():
)


def test_list_image_versions(
transport: str = "grpc", request_type=image_versions.ListImageVersionsRequest
):
@pytest.mark.parametrize(
"request_type", [image_versions.ListImageVersionsRequest, dict,]
)
def test_list_image_versions(request_type, transport: str = "grpc"):
client = ImageVersionsClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -514,10 +515,6 @@ def test_list_image_versions(
assert response.next_page_token == "next_page_token_value"


def test_list_image_versions_from_dict():
test_list_image_versions(request_type=dict)


def test_list_image_versions_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -708,8 +705,10 @@ async def test_list_image_versions_flattened_error_async():
)


def test_list_image_versions_pager():
client = ImageVersionsClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_image_versions_pager(transport_name: str = "grpc"):
client = ImageVersionsClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -753,8 +752,10 @@ def test_list_image_versions_pager():
assert all(isinstance(i, image_versions.ImageVersion) for i in results)


def test_list_image_versions_pages():
client = ImageVersionsClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_image_versions_pages(transport_name: str = "grpc"):
client = ImageVersionsClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -1360,7 +1361,7 @@ def test_parse_common_location_path():
assert expected == actual


def test_client_withDEFAULT_CLIENT_INFO():
def test_client_with_default_client_info():
client_info = gapic_v1.client_info.ClientInfo()

with mock.patch.object(
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.