| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,7 @@ class ClientInfo(object): | |||
| 59 | 59 | Recommended format: ``application-or-tool-ID/major.minor.version``. | |
| 60 | 60 | rest_version (Optional[str]): A string with labeled versions of the | |
| 61 | 61 | dependencies used for REST transport. | |
| 62 | + protobuf_runtime_version (Optional[str]): The protobuf runtime version. | ||
| 62 | 63 | """ | |
| 63 | 64 | ||
| 64 | 65 | def __init__( | |
@@ -70,6 +71,7 @@ def __init__( | |||
| 70 | 71 | client_library_version=None, | |
| 71 | 72 | user_agent=None, | |
| 72 | 73 | rest_version=None, | |
| 74 | + protobuf_runtime_version=None, | ||
| 73 | 75 | ): | |
| 74 | 76 | self.python_version = python_version | |
| 75 | 77 | self.grpc_version = grpc_version | |
@@ -78,6 +80,7 @@ def __init__( | |||
| 78 | 80 | self.client_library_version = client_library_version | |
| 79 | 81 | self.user_agent = user_agent | |
| 80 | 82 | self.rest_version = rest_version | |
| 83 | + self.protobuf_runtime_version = protobuf_runtime_version | ||
| 81 | 84 | ||
| 82 | 85 | def to_user_agent(self): | |
| 83 | 86 | """Returns the user-agent string for this client info.""" | |
@@ -105,4 +108,7 @@ def to_user_agent(self): | |||
| 105 | 108 | if self.client_library_version is not None: | |
| 106 | 109 | ua += "gccl/{client_library_version} " | |
| 107 | 110 | ||
| 111 | + if self.protobuf_runtime_version is not None: | ||
| 112 | + ua += "pb/{protobuf_runtime_version} " | ||
| 113 | + | ||
| 108 | 114 | return ua.format(**self.__dict__).strip() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,6 +47,7 @@ class ClientInfo(client_info.ClientInfo): | |||
| 47 | 47 | Recommended format: ``application-or-tool-ID/major.minor.version``. | |
| 48 | 48 | rest_version (Optional[str]): A string with labeled versions of the | |
| 49 | 49 | dependencies used for REST transport. | |
| 50 | + protobuf_runtime_version (Optional[str]): The protobuf runtime version. | ||
| 50 | 51 | """ | |
| 51 | 52 | ||
| 52 | 53 | def to_grpc_metadata(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,6 +81,7 @@ async def test_wrap_method_with_custom_client_info(): | |||
| 81 | 81 | api_core_version=3, | |
| 82 | 82 | gapic_version=4, | |
| 83 | 83 | client_library_version=5, | |
| 84 | + protobuf_runtime_version=6, | ||
| 84 | 85 | ) | |
| 85 | 86 | fake_call = grpc_helpers_async.FakeUnaryUnaryCall() | |
| 86 | 87 | method = mock.Mock(spec=aio.UnaryUnaryMultiCallable, return_value=fake_call) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,7 @@ def test_wrap_method_with_custom_client_info(): | |||
| 76 | 76 | api_core_version=3, | |
| 77 | 77 | gapic_version=4, | |
| 78 | 78 | client_library_version=5, | |
| 79 | + protobuf_runtime_version=6, | ||
| 79 | 80 | ) | |
| 80 | 81 | method = mock.Mock(spec=["__call__"]) | |
| 81 | 82 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,7 @@ def test_constructor_options(): | |||
| 46 | 46 | client_library_version="5", | |
| 47 | 47 | user_agent="6", | |
| 48 | 48 | rest_version="7", | |
| 49 | + protobuf_runtime_version="8", | ||
| 49 | 50 | ) | |
| 50 | 51 | ||
| 51 | 52 | assert info.python_version == "1" | |
@@ -55,11 +56,15 @@ def test_constructor_options(): | |||
| 55 | 56 | assert info.client_library_version == "5" | |
| 56 | 57 | assert info.user_agent == "6" | |
| 57 | 58 | assert info.rest_version == "7" | |
| 59 | + assert info.protobuf_runtime_version == "8" | ||
| 58 | 60 | ||
| 59 | 61 | ||
| 60 | 62 | def test_to_user_agent_minimal(): | |
| 61 | 63 | info = client_info.ClientInfo( | |
| 62 | - python_version="1", api_core_version="2", grpc_version=None | ||
| 64 | + python_version="1", | ||
| 65 | + api_core_version="2", | ||
| 66 | + grpc_version=None, | ||
| 67 | + protobuf_runtime_version=None, | ||
| 63 | 68 | ) | |
| 64 | 69 | ||
| 65 | 70 | user_agent = info.to_user_agent() | |
@@ -75,11 +80,12 @@ def test_to_user_agent_full(): | |||
| 75 | 80 | gapic_version="4", | |
| 76 | 81 | client_library_version="5", | |
| 77 | 82 | user_agent="app-name/1.0", | |
| 83 | + protobuf_runtime_version="6", | ||
| 78 | 84 | ) | |
| 79 | 85 | ||
| 80 | 86 | user_agent = info.to_user_agent() | |
| 81 | 87 | ||
| 82 | - assert user_agent == "app-name/1.0 gl-python/1 grpc/2 gax/3 gapic/4 gccl/5" | ||
| 88 | + assert user_agent == "app-name/1.0 gl-python/1 grpc/2 gax/3 gapic/4 gccl/5 pb/6" | ||
| 83 | 89 | ||
| 84 | 90 | ||
| 85 | 91 | def test_to_user_agent_rest(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments