File: test_inputfield.py

package info (click to toggle)
python-graphene 2.1.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,024 kB
  • sloc: python: 7,295; makefile: 196; sh: 4
file content (29 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from functools import partial

from ..inputfield import InputField
from ..structures import NonNull
from .utils import MyLazyType


def test_inputfield_required():
    MyType = object()
    field = InputField(MyType, required=True)
    assert isinstance(field.type, NonNull)
    assert field.type.of_type == MyType


def test_inputfield_with_lazy_type():
    MyType = object()
    field = InputField(lambda: MyType)
    assert field.type == MyType


def test_inputfield_with_lazy_partial_type():
    MyType = object()
    field = InputField(partial(lambda: MyType))
    assert field.type == MyType


def test_inputfield_with_string_type():
    field = InputField("graphene.types.tests.utils.MyLazyType")
    assert field.type == MyLazyType