@@ -81,9 +81,9 @@ def test_should_unicodetext_convert_string():
81
81
82
82
def test_should_enum_convert_enum ():
83
83
field = assert_column_conversion (
84
- types .Enum (enum . Enum ( 'TwoNumbersPyEnum ' , 'one two' ) ), graphene .Field )
84
+ types .Enum ('one ' , 'two' ), graphene .Field )
85
85
field_type = field .type ()
86
- assert field_type .__class__ .__name__ == 'TwoNumbersPyEnum'
86
+ assert field_type .__class__ .__name__ . startswith ( 'Enum' )
87
87
assert isinstance (field_type , graphene .Enum )
88
88
assert hasattr (field_type , 'ONE' )
89
89
assert not hasattr (field_type , 'one' )
@@ -96,6 +96,28 @@ def test_should_enum_convert_enum():
96
96
assert hasattr (field_type , 'ONE' )
97
97
assert not hasattr (field_type , 'one' )
98
98
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 )
99
121
100
122
101
123
def test_should_small_integer_convert_int ():
0 commit comments