@@ -1128,6 +1128,73 @@ def test_to_api_repr_parameterized(field, api):
11281128 assert SchemaField (** field ).to_api_repr () == api
11291129
11301130
1131+ class TestForeignTypeInfo :
1132+ """Tests for ForeignTypeInfo objects."""
1133+
1134+ @staticmethod
1135+ def _get_target_class ():
1136+ from google .cloud .bigquery .schema import ForeignTypeInfo
1137+
1138+ return ForeignTypeInfo
1139+
1140+ def _make_one (self , * args , ** kw ):
1141+ return self ._get_target_class ()(* args , ** kw )
1142+
1143+ @pytest .mark .parametrize (
1144+ "type_system,expected" ,
1145+ [
1146+ (None , None ),
1147+ ("TYPE_SYSTEM_UNSPECIFIED" , "TYPE_SYSTEM_UNSPECIFIED" ),
1148+ ("HIVE" , "HIVE" ),
1149+ ],
1150+ )
1151+ def test_ctor_valid_input (self , type_system , expected ):
1152+ result = self ._make_one (type_system = type_system )
1153+
1154+ assert result .type_system == expected
1155+
1156+ def test_ctor_invalid_input (self ):
1157+ with pytest .raises (TypeError ) as e :
1158+ self ._make_one (type_system = 123 )
1159+
1160+ # Looking for the first word from the string "Pass <variable> as..."
1161+ assert "Pass " in str (e .value )
1162+
1163+ @pytest .mark .parametrize (
1164+ "type_system,expected" ,
1165+ [
1166+ ("TYPE_SYSTEM_UNSPECIFIED" , {"typeSystem" : "TYPE_SYSTEM_UNSPECIFIED" }),
1167+ ("HIVE" , {"typeSystem" : "HIVE" }),
1168+ (None , {"typeSystem" : None }),
1169+ ],
1170+ )
1171+ def test_to_api_repr (self , type_system , expected ):
1172+ result = self ._make_one (type_system = type_system )
1173+
1174+ assert result .to_api_repr () == expected
1175+
1176+ def test_from_api_repr (self ):
1177+ """GIVEN an api representation of a ForeignTypeInfo object (i.e. api_repr)
1178+ WHEN converted into a ForeignTypeInfo object using from_api_repr()
1179+ THEN it will have the same representation in dict format as a ForeignTypeInfo
1180+ object made directly (via _make_one()) and represented in dict format.
1181+ """
1182+ api_repr = {
1183+ "typeSystem" : "TYPE_SYSTEM_UNSPECIFIED" ,
1184+ }
1185+
1186+ expected = self ._make_one (
1187+ type_system = "TYPE_SYSTEM_UNSPECIFIED" ,
1188+ )
1189+
1190+ klass = self ._get_target_class ()
1191+ result = klass .from_api_repr (api_repr )
1192+
1193+ # We convert both to dict format because these classes do not have a
1194+ # __eq__() method to facilitate direct equality comparisons.
1195+ assert result .to_api_repr () == expected .to_api_repr ()
1196+
1197+
11311198class TestSerDeInfo :
11321199 """Tests for the SerDeInfo class."""
11331200
@@ -1190,9 +1257,9 @@ def test_to_api_repr(self):
11901257 assert serde_info .to_api_repr () == expected_repr
11911258
11921259 def test_from_api_repr (self ):
1193- """GIVEN an api representation of a SerDeInfo object (i.e. resource )
1260+ """GIVEN an api representation of a SerDeInfo object (i.e. api_repr )
11941261 WHEN converted into a SerDeInfo object using from_api_repr()
1195- THEN it will have the representation in dict format as a SerDeInfo
1262+ THEN it will have the same representation in dict format as a SerDeInfo
11961263 object made directly (via _make_one()) and represented in dict format.
11971264 """
11981265 api_repr = {
0 commit comments