@@ -35,7 +35,6 @@ def test_edmx(schema):
3535 'CarIDPic' ,
3636 'Customer' ,
3737 'Order' ,
38- 'EnumTest'
3938 }
4039
4140 assert set ((entity_set .name for entity_set in schema .entity_sets )) == {
@@ -51,12 +50,6 @@ def test_edmx(schema):
5150 'CarIDPics' ,
5251 'Customers' ,
5352 'Orders' ,
54- 'EnumTests'
55- }
56-
57- assert set ((enum_type .name for enum_type in schema .enum_types )) == {
58- 'Country' ,
59- 'Language'
6053 }
6154
6255 master_entity = schema .entity_type ('MasterEntity' )
@@ -879,8 +872,6 @@ def test_null_type(xml_builder_factory):
879872 <Property Name="Key" Type="Edm.UnknownType" />
880873 </EntityType>
881874
882- <EnumType Name="MasterEnum" UnderlyingType="Edm.String" />
883-
884875 <ComplexType Name="MasterComplex">
885876 <Property Name="Width" Type="Edm.Double" />
886877 <Property Name="Width" Type="Edm.Double" />
@@ -903,8 +894,6 @@ def test_null_type(xml_builder_factory):
903894 type_info = TypeInfo (namespace = None , name = 'MasterProperty' , is_collection = False )
904895 assert isinstance (schema .get_type (type_info ).proprty ('Key' ).typ , NullType )
905896
906- type_info = TypeInfo (namespace = None , name = 'MasterEnum' , is_collection = False )
907- assert isinstance (schema .get_type (type_info ), NullType )
908897
909898 type_info = TypeInfo (namespace = None , name = 'MasterComplex' , is_collection = False )
910899 assert isinstance (schema .get_type (type_info ), NullType )
@@ -1175,77 +1164,6 @@ def test_whitelisted_edm_namespace_2007_05(mocked, xml_builder_factory):
11751164 mocked .assert_called_once ()
11761165
11771166
1178- def test_enum_parsing (schema ):
1179- """Test correct parsing of enum"""
1180-
1181- country = schema .enum_type ('Country' ).USA
1182- assert str (country ) == "Country'USA'"
1183-
1184- country2 = schema .enum_type ('Country' )['USA' ]
1185- assert str (country2 ) == "Country'USA'"
1186-
1187- try :
1188- schema .enum_type ('Country' ).Cyprus
1189- except PyODataException as ex :
1190- assert str (ex ) == f'EnumType EnumType(Country) has no member Cyprus'
1191-
1192- c = schema .enum_type ('Country' )[1 ]
1193- assert str (c ) == "Country'China'"
1194-
1195- try :
1196- schema .enum_type ('Country' )[15 ]
1197- except PyODataException as ex :
1198- assert str (ex ) == f'EnumType EnumType(Country) has no member with value { 15 } '
1199-
1200- type_info = TypeInfo (namespace = None , name = 'Country' , is_collection = False )
1201-
1202- try :
1203- schema .get_type (type_info )
1204- except PyODataModelError as ex :
1205- assert str (ex ) == f'Neither primitive types nor types parsed from service metadata contain requested type { type_info [0 ]} '
1206-
1207- language = schema .enum_type ('Language' )
1208- assert language .is_flags is True
1209-
1210- try :
1211- schema .enum_type ('ThisEnumDoesNotExist' )
1212- except KeyError as ex :
1213- assert str (ex ) == f'\' EnumType ThisEnumDoesNotExist does not exist in any Schema Namespace\' '
1214-
1215- try :
1216- schema .enum_type ('Country' , 'WrongNamespace' ).USA
1217- except KeyError as ex :
1218- assert str (ex ) == '\' EnumType Country does not exist in Schema Namespace WrongNamespace\' '
1219-
1220-
1221- def test_unsupported_enum_underlying_type (xml_builder_factory ):
1222- """Test if parser will parse only allowed underlying types"""
1223- xml_builder = xml_builder_factory ()
1224- xml_builder .add_schema ('Test' , '<EnumType Name="UnsupportedEnumType" UnderlyingType="Edm.Bool" />' )
1225- xml = xml_builder .serialize ()
1226-
1227- try :
1228- MetadataBuilder (xml ).build ()
1229- except PyODataParserError as ex :
1230- assert str (ex ).startswith (f'Type Edm.Bool is not valid as underlying type for EnumType - must be one of' )
1231-
1232-
1233- def test_enum_value_out_of_range (xml_builder_factory ):
1234- """Test if parser will check for values ot of range defined by underlying type"""
1235- xml_builder = xml_builder_factory ()
1236- xml_builder .add_schema ('Test' , """
1237- <EnumType Name="Num" UnderlyingType="Edm.Byte">
1238- <Member Name="TooBig" Value="-130" />
1239- </EnumType>
1240- """ )
1241- xml = xml_builder .serialize ()
1242-
1243- try :
1244- MetadataBuilder (xml ).build ()
1245- except BaseException as ex :
1246- assert str (ex ) == f'Value -130 is out of range for type Edm.Byte'
1247-
1248-
12491167@patch ('logging.Logger.warning' )
12501168def test_missing_property_referenced_in_annotation (mock_warning , xml_builder_factory ):
12511169 """Test that correct behavior when non existing property is referenced in annotation"""
0 commit comments