Skip to content

Commit

Permalink
parametrize target in def test_create_channel_implicit
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Feb 4, 2024
1 parent d63402e commit 396d8fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions tests/asyncio/test_grpc_helpers_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ def test_wrap_errors_streaming(wrap_stream_errors):


@pytest.mark.parametrize(
"attempt_direct_path,expected_target",
"attempt_direct_path,target,expected_target",
[
(None, "example.com:443"),
(False, "example.com:443"),
(True, "google-c2p:///example.com"),
(None, "example.com:443", "example.com:443"),
(False, "example.com:443", "example.com:443"),
(True, "example.com:443", "google-c2p:///example.com"),
(True, "dns:///example.com", "google-c2p:///example.com"),
(True, "another-c2p:///example.com", "another-c2p:///example.com"),
],
)
@mock.patch("grpc.compute_engine_channel_credentials")
Expand All @@ -318,9 +320,9 @@ def test_create_channel_implicit(
google_auth_default,
composite_creds_call,
attempt_direct_path,
target,
expected_target,
):
target = "example.com:443"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers_async.create_channel(
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/test_grpc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,13 @@ def test_wrap_errors_streaming(wrap_stream_errors):


@pytest.mark.parametrize(
"attempt_direct_path,expected_target",
"attempt_direct_path,target,expected_target",
[
(None, "example.com:443"),
(False, "example.com:443"),
(True, "google-c2p:///example.com"),
(None, "example.com:443", "example.com:443"),
(False, "example.com:443", "example.com:443"),
(True, "example.com:443", "google-c2p:///example.com"),
(True, "dns:///example.com", "google-c2p:///example.com"),
(True, "another-c2p:///example.com", "another-c2p:///example.com"),
],
)
@mock.patch("grpc.compute_engine_channel_credentials")
Expand All @@ -385,9 +387,9 @@ def test_create_channel_implicit(
google_auth_default,
composite_creds_call,
attempt_direct_path,
target,
expected_target,
):
target = "example.com:443"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers.create_channel(
Expand Down

0 comments on commit 396d8fa

Please sign in to comment.