@@ -81,9 +81,9 @@ def test_should_unicodetext_convert_string():
8181
8282def test_should_enum_convert_enum ():
8383 field = assert_column_conversion (
84- types .Enum (enum . Enum ( 'TwoNumbersPyEnum ' , 'one two' ) ), graphene .Field )
84+ types .Enum ('one ' , 'two' ), graphene .Field )
8585 field_type = field .type ()
86- assert field_type .__class__ .__name__ == 'TwoNumbersPyEnum'
86+ assert field_type .__class__ .__name__ . startswith ( 'Enum' )
8787 assert isinstance (field_type , graphene .Enum )
8888 assert hasattr (field_type , 'ONE' )
8989 assert not hasattr (field_type , 'one' )
@@ -96,6 +96,28 @@ def test_should_enum_convert_enum():
9696 assert hasattr (field_type , 'ONE' )
9797 assert not hasattr (field_type , 'one' )
9898 assert hasattr (field_type , 'TWO' )
99+ field = assert_column_conversion (
100+ types .Enum (enum .Enum ('TwoNumbersPyEnum' , 'one two' )), graphene .Field )
101+ field_type = field .type ()
102+ assert field_type .__class__ .__name__ == 'TwoNumbersPyEnum'
103+ assert isinstance (field_type , graphene .Enum )
104+ assert hasattr (field_type , 'ONE' )
105+ assert not hasattr (field_type , 'one' )
106+ assert hasattr (field_type , 'TWO' )
107+
108+
109+ def test_should_conflicting_enum_raise_error ():
110+ some_type = types .Enum (enum .Enum ('ConflictingEnum' , 'cat cow' ))
111+ field = assert_column_conversion (some_type , graphene .Field )
112+ field_type = field .type ()
113+ assert isinstance (field_type , graphene .Enum )
114+ assert hasattr (field_type , 'COW' )
115+ same_type = types .Enum (enum .Enum ('ConflictingEnum' , 'cat cow' ))
116+ field = assert_column_conversion (same_type , graphene .Field )
117+ assert field_type == field .type ()
118+ conflicting_type = types .Enum (enum .Enum ('ConflictingEnum' , 'cat horse' ))
119+ with raises (TypeError ):
120+ assert_column_conversion (conflicting_type , graphene .Field )
99121
100122
101123def test_should_small_integer_convert_int ():
0 commit comments