@@ -681,21 +681,6 @@ def test_from_api_repr_none(self):
681681 self .assertEqual (None , self ._get_target_class ().from_api_repr (None ))
682682
683683
684- # TODO: dedup with the same class in test_table.py.
685- class _SchemaBase (object ):
686- def _verify_field (self , field , r_field ):
687- self .assertEqual (field .name , r_field ["name" ])
688- self .assertEqual (field .field_type , r_field ["type" ])
689- self .assertEqual (field .mode , r_field .get ("mode" , "NULLABLE" ))
690-
691- def _verifySchema (self , schema , resource ):
692- r_fields = resource ["schema" ]["fields" ]
693- self .assertEqual (len (schema ), len (r_fields ))
694-
695- for field , r_field in zip (schema , r_fields ):
696- self ._verify_field (field , r_field )
697-
698-
699684# BEGIN PYTEST BASED SCHEMA TESTS ====================
700685@pytest .fixture
701686def basic_resource ():
@@ -902,6 +887,18 @@ def test_valid_mapping_representation(self, schema, expected_schema):
902887 result = _to_schema_fields (schema )
903888 assert result == expected_schema
904889
890+ def test_valid_schema_object (self ):
891+ schema = Schema (
892+ fields = [SchemaField ("name" , "STRING" )],
893+ foreign_type_info = "TestInfo" ,
894+ )
895+ result = _to_schema_fields (schema )
896+ expected = Schema (
897+ [SchemaField ("name" , "STRING" , "NULLABLE" , None , None , (), None )],
898+ "TestInfo" ,
899+ )
900+ assert result .to_api_repr () == expected .to_api_repr ()
901+
905902
906903# Testing the new Schema Class =================
907904class TestSchemaObject : # New test class for Schema object interactions
@@ -926,6 +923,16 @@ def test_schema_object_foreign_type_info(self):
926923 with pytest .raises (TypeError ):
927924 schema .foreign_type_info = 123 # Type check
928925
926+ def test_str (self ):
927+ schema = Schema (
928+ fields = [SchemaField ("name" , "STRING" )],
929+ foreign_type_info = "TestInfo" ,
930+ )
931+ assert (
932+ str (schema )
933+ == "Schema([SchemaField('name', 'STRING', 'NULLABLE', None, None, (), None)], TestInfo)"
934+ )
935+
929936 @pytest .mark .parametrize (
930937 "schema, expected_repr" ,
931938 [
@@ -1434,15 +1441,16 @@ def test_ctor_valid_input(
14341441 output_format = output_format ,
14351442 serde_info = serde_info ,
14361443 )
1437- assert storage_descriptor ._properties ["inputFormat" ] == input_format
1438- assert storage_descriptor ._properties ["locationUri" ] == location_uri
1439- assert storage_descriptor ._properties ["outputFormat" ] == output_format
1444+ assert storage_descriptor .input_format == input_format
1445+ assert storage_descriptor .location_uri == location_uri
1446+ assert storage_descriptor .output_format == output_format
1447+
14401448 if serde_info is not None :
14411449 assert (
1442- storage_descriptor ._properties [ "serDeInfo" ] == serde_info .to_api_repr ()
1450+ storage_descriptor .serde_info . to_api_repr () == serde_info .to_api_repr ()
14431451 )
14441452 else :
1445- assert storage_descriptor ._properties [ "serDeInfo" ] == serde_info
1453+ assert storage_descriptor .serde_info is None
14461454
14471455 @pytest .mark .parametrize (
14481456 "input_format,location_uri,output_format,serde_info" ,
0 commit comments