From 6d536e637cc526a1642e2241f247bf0fcd2d58f7 Mon Sep 17 00:00:00 2001 From: Kajetan Boroszko Date: Wed, 7 Aug 2024 13:13:30 +0200 Subject: [PATCH] fix tests --- google/cloud/bigtable/data/_async/client.py | 2 +- .../execute_query/_parameters_formatting.py | 2 +- .../bigtable/data/execute_query/metadata.py | 2 +- tests/system/data/test_execute_query_utils.py | 17 ++++++++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/google/cloud/bigtable/data/_async/client.py b/google/cloud/bigtable/data/_async/client.py index d75d557e8..600937df8 100644 --- a/google/cloud/bigtable/data/_async/client.py +++ b/google/cloud/bigtable/data/_async/client.py @@ -503,7 +503,7 @@ async def execute_query( request_body = { "instance_name": instance_name, "app_profile_id": app_profile_id, - "query_string": query, + "query": query, "params": pb_params, "proto_format": {}, } diff --git a/google/cloud/bigtable/data/execute_query/_parameters_formatting.py b/google/cloud/bigtable/data/execute_query/_parameters_formatting.py index c1478d7bb..edb7a6380 100644 --- a/google/cloud/bigtable/data/execute_query/_parameters_formatting.py +++ b/google/cloud/bigtable/data/execute_query/_parameters_formatting.py @@ -84,7 +84,7 @@ def _convert_value_to_pb_value_dict( """ # type field will be set only in top-level Value. value_dict = param_type._to_value_pb_dict(value) - value_dict["type"] = param_type._to_type_pb_dict() + value_dict["type_"] = param_type._to_type_pb_dict() return value_dict diff --git a/google/cloud/bigtable/data/execute_query/metadata.py b/google/cloud/bigtable/data/execute_query/metadata.py index 19bd136ba..5a985f71a 100644 --- a/google/cloud/bigtable/data/execute_query/metadata.py +++ b/google/cloud/bigtable/data/execute_query/metadata.py @@ -89,7 +89,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return self.__str__() - class Struct(_NamedList["SqlType.Type"], "SqlType.Type"): + class Struct(_NamedList[Type], Type): @classmethod def from_pb_type(cls, type_pb: Optional[PBType] = None) -> "SqlType.Struct": if type_pb is None: diff --git a/tests/system/data/test_execute_query_utils.py b/tests/system/data/test_execute_query_utils.py index 726fe5540..9e27b95f2 100644 --- a/tests/system/data/test_execute_query_utils.py +++ b/tests/system/data/test_execute_query_utils.py @@ -39,6 +39,21 @@ def async_mock(return_value=None): return AsyncMock(return_value=return_value) +# ExecuteQueryResponse( +# metadata={ +# "proto_schema": { +# "columns": [ +# {"name": "test1", "type_": TYPE_INT}, +# {"name": "test2", "type_": TYPE_INT}, +# ] +# } +# } +# ), +# ExecuteQueryResponse( +# results={"proto_rows_batch": {"batch_data": messages[0]}} +# ), + + def response_with_metadata(): schema = {"a": "string_type", "b": "int64_type"} return ExecuteQueryResponse( @@ -46,7 +61,7 @@ def response_with_metadata(): "metadata": { "proto_schema": { "columns": [ - {"name": name, "type": {_type: {}}} + {"name": name, "type_": {_type: {}}} for name, _type in schema.items() ] }