Skip to content

Commit ab209c4

Browse files
committed
Add tests for supporting Iterable collections across the lib
Replicates graphql/graphql-js@61c2b01
1 parent f5b0980 commit ab209c4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/utilities/test_ast_from_value.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ def converts_list_values_to_list_asts():
207207
values=[EnumValueNode(value="HELLO"), EnumValueNode(value="GOODBYE")]
208208
)
209209

210+
def list_generator():
211+
yield 1
212+
yield 2
213+
yield 3
214+
215+
assert ast_from_value(list_generator(), GraphQLList(GraphQLInt)) == (
216+
ListValueNode(
217+
values=[
218+
IntValueNode(value="1"),
219+
IntValueNode(value="2"),
220+
IntValueNode(value="3"),
221+
]
222+
)
223+
)
224+
210225
def converts_list_singletons():
211226
assert ast_from_value("FOO", GraphQLList(GraphQLString)) == StringValueNode(
212227
value="FOO"

tests/utilities/test_coerce_input_value.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ def returns_no_error_for_a_valid_input():
285285
result = _coerce_value([1, 2, 3], TestList)
286286
assert expect_value(result) == [1, 2, 3]
287287

288+
def returns_no_error_for_a_valid_iterable_input():
289+
def list_generator():
290+
yield 1
291+
yield 2
292+
yield 3
293+
294+
result = _coerce_value(list_generator(), TestList)
295+
assert expect_value(result) == [1, 2, 3]
296+
288297
def returns_an_error_for_an_invalid_input():
289298
result = _coerce_value([1, "b", True, 4], TestList)
290299
assert expect_errors(result) == [

0 commit comments

Comments
 (0)