Skip to content

Commit 67c0182

Browse files
committed
Clean up some failing tests
1 parent ba2795b commit 67c0182

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

google/cloud/bigquery/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import collections
2020
import copy
2121
import enum
22-
from typing import Any, cast, Dict, Iterable, Optional, Union, Mapping, List
22+
from typing import Any, cast, Dict, Iterable, Optional, Union, List
2323

2424
from google.cloud.bigquery import _helpers
2525
from google.cloud.bigquery import standard_sql
@@ -264,11 +264,11 @@ def __init__(
264264
self._properties["fields"] = [field.to_api_repr() for field in fields]
265265

266266
@classmethod
267-
def from_api_repr(cls, api_repr: Mapping[str, Any]) -> "SchemaField":
267+
def from_api_repr(cls, api_repr: Dict[str, Any]) -> "SchemaField":
268268
"""Return a ``SchemaField`` object deserialized from a dictionary.
269269
270270
Args:
271-
api_repr (Mapping[str, str]): The serialized representation
271+
api_repr (Dict[str, str]): The serialized representation
272272
of the SchemaField, such as what is output by
273273
:meth:`to_api_repr`.
274274
@@ -514,7 +514,7 @@ def _build_schema_resource(fields):
514514

515515

516516
def _to_schema_fields(
517-
schema: Union[Schema, List[Union[SchemaField, Mapping[str, Any]]]]
517+
schema: Union[Schema, List[Union[SchemaField, Dict[str, Any]]]]
518518
) -> Union[Schema, List[SchemaField]]:
519519
"""Convert the input to either a Schema object OR a list of SchemaField objects.
520520

tests/unit/test_schema.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,12 @@ def test_build_schema_resource(self, fields, expected_resource):
831831

832832

833833
class TestToSchemaFields: # Test class for _to_schema_fields
834+
@staticmethod
835+
def _call_fut(schema):
836+
from google.cloud.bigquery.schema import _to_schema_fields
837+
838+
return _to_schema_fields(schema)
839+
834840
def test_invalid_type(self):
835841
"""Invalid list of tuples instead of list of mappings"""
836842
schema = [
@@ -956,7 +962,7 @@ def test_str(self):
956962
)
957963
assert (
958964
str(schema)
959-
== "Schema([{'name': 'name', 'mode': 'NULLABLE', 'type': 'STRING'}], TestInfo)"
965+
== "Schema([{'name': 'name', 'type': 'STRING', 'mode': 'NULLABLE'}], TestInfo)"
960966
)
961967

962968
@pytest.mark.parametrize(
@@ -967,12 +973,12 @@ def test_str(self):
967973
fields=[SchemaField("name", "STRING")],
968974
foreign_type_info="TestInfo",
969975
),
970-
"Schema([{'name': 'name', 'mode': 'NULLABLE', 'type': 'STRING'}], 'TestInfo')",
976+
"Schema([{'name': 'name', 'type': 'STRING', 'mode': 'NULLABLE'}], 'TestInfo')",
971977
id="repr with foreign type info",
972978
),
973979
pytest.param(
974980
Schema(fields=[SchemaField("name", "STRING")]),
975-
"Schema([{'name': 'name', 'mode': 'NULLABLE', 'type': 'STRING'}], None)",
981+
"Schema([{'name': 'name', 'type': 'STRING', 'mode': 'NULLABLE'}], None)",
976982
id="repr without foreign type info",
977983
),
978984
],

0 commit comments

Comments
 (0)