|
1 | 1 |
|
2 |
| -from ...types import AbstractType, Field, List, NonNull, ObjectType, String |
3 |
| -from ..connection import Connection, PageInfo |
| 2 | +from ...types import AbstractType, Field, List, NonNull, ObjectType, String, Argument, Int |
| 3 | +from ..connection import Connection, PageInfo, ConnectionField |
4 | 4 | from ..node import Node
|
5 | 5 |
|
6 | 6 |
|
@@ -109,3 +109,32 @@ def test_pageinfo():
|
109 | 109 | assert PageInfo._meta.name == 'PageInfo'
|
110 | 110 | fields = PageInfo._meta.fields
|
111 | 111 | assert list(fields.keys()) == ['has_next_page', 'has_previous_page', 'start_cursor', 'end_cursor']
|
| 112 | + |
| 113 | + |
| 114 | +def test_connectionfield(): |
| 115 | + class MyObjectConnection(Connection): |
| 116 | + class Meta: |
| 117 | + node = MyObject |
| 118 | + |
| 119 | + field = ConnectionField(MyObjectConnection) |
| 120 | + assert field.args == { |
| 121 | + 'before': Argument(String), |
| 122 | + 'after': Argument(String), |
| 123 | + 'first': Argument(Int), |
| 124 | + 'last': Argument(Int), |
| 125 | + } |
| 126 | + |
| 127 | + |
| 128 | +def test_connectionfield_custom_args(): |
| 129 | + class MyObjectConnection(Connection): |
| 130 | + class Meta: |
| 131 | + node = MyObject |
| 132 | + |
| 133 | + field = ConnectionField(MyObjectConnection, before=String(required=True), extra=String()) |
| 134 | + assert field.args == { |
| 135 | + 'before': Argument(NonNull(String)), |
| 136 | + 'after': Argument(String), |
| 137 | + 'first': Argument(Int), |
| 138 | + 'last': Argument(Int), |
| 139 | + 'extra': Argument(String), |
| 140 | + } |
0 commit comments