Skip to content

Commit 1840814

Browse files
author
Nicolas Maurice
committed
group custom option tests into one test
1 parent 3e1b7fb commit 1840814

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

graphene_sqlalchemy/tests/test_types.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
from collections import OrderedDict
22
from graphene import Field, Int, Interface, ObjectType
33
from graphene.relay import Node, is_node
44
import six
@@ -121,30 +121,34 @@ def test_custom_objecttype_registered():
121121
# Test Custom SQLAlchemyObjectType with Custom Options
122122
class CustomOptions(SQLAlchemyObjectTypeOptions):
123123
custom_option = None
124+
custom_fields = None
124125

125126

126127
class SQLAlchemyObjectTypeWithCustomOptions(SQLAlchemyObjectType):
127128
class Meta:
128129
abstract = True
129130

130131
@classmethod
131-
def __init_subclass_with_meta__(cls, custom_option=None, **options):
132+
def __init_subclass_with_meta__(cls, custom_option=None, custom_fields=None, **options):
132133
_meta = CustomOptions(cls)
133134
_meta.custom_option = custom_option
135+
_meta.fields = custom_fields
134136
super(SQLAlchemyObjectTypeWithCustomOptions, cls).__init_subclass_with_meta__(_meta=_meta, **options)
135137

136138

137139
class ReporterWithCustomOptions(SQLAlchemyObjectTypeWithCustomOptions):
138140
class Meta:
139141
model = Reporter
140142
custom_option = 'custom_option'
143+
custom_fields = OrderedDict([('custom_field', Field(Int()))])
141144

142145

143146
def test_objecttype_with_custom_options():
144147
assert issubclass(ReporterWithCustomOptions, ObjectType)
145148
assert ReporterWithCustomOptions._meta.model == Reporter
146149
assert list(
147150
ReporterWithCustomOptions._meta.fields.keys()) == [
151+
'custom_field',
148152
'id',
149153
'first_name',
150154
'last_name',
@@ -153,28 +157,4 @@ def test_objecttype_with_custom_options():
153157
'articles',
154158
'favorite_article']
155159
assert ReporterWithCustomOptions._meta.custom_option == 'custom_option'
156-
157-
158-
class ReporterWithCustomOptionsAndField(SQLAlchemyObjectTypeWithCustomOptions):
159-
class Meta:
160-
model = Reporter
161-
custom_option = 'custom_option'
162-
163-
custom_field = Field(Int())
164-
165-
166-
def test_objecttype_with_custom_options_and_field():
167-
assert issubclass(ReporterWithCustomOptions, ObjectType)
168-
assert ReporterWithCustomOptions._meta.model == Reporter
169-
assert list(
170-
ReporterWithCustomOptionsAndField._meta.fields.keys()) == [
171-
'id',
172-
'first_name',
173-
'last_name',
174-
'email',
175-
'pets',
176-
'articles',
177-
'favorite_article',
178-
'custom_field']
179-
assert ReporterWithCustomOptionsAndField._meta.custom_option == 'custom_option'
180-
assert isinstance(ReporterWithCustomOptionsAndField._meta.fields['custom_field'].type, Int)
160+
assert isinstance(ReporterWithCustomOptions._meta.fields['custom_field'].type, Int)

0 commit comments

Comments
 (0)