Improved Field coverage

This commit is contained in:
Syrus Akbary 2016-10-21 09:22:19 -07:00
parent d7fded7d98
commit ecdfed257c

View File

@ -3,6 +3,7 @@ import pytest
from ..argument import Argument from ..argument import Argument
from ..field import Field from ..field import Field
from ..structures import NonNull from ..structures import NonNull
from ..scalars import String
class MyInstance(object): class MyInstance(object):
@ -75,6 +76,20 @@ def test_field_source_func():
assert field.resolver(MyInstance(), {}, None, None) == MyInstance.value_func() assert field.resolver(MyInstance(), {}, None, None) == MyInstance.value_func()
def test_field_source_as_argument():
MyType = object()
field = Field(MyType, source=String())
assert 'source' in field.args
assert field.args['source'].type == String
def test_field_name_as_argument():
MyType = object()
field = Field(MyType, name=String())
assert 'name' in field.args
assert field.args['name'].type == String
def test_field_source_argument_as_kw(): def test_field_source_argument_as_kw():
MyType = object() MyType = object()
field = Field(MyType, b=NonNull(True), c=Argument(None), a=NonNull(False)) field = Field(MyType, b=NonNull(True), c=Argument(None), a=NonNull(False))