-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved arguments and structures comparison
- Loading branch information
1 parent
c792923
commit bd207b5
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from ..argument import Argument | ||
from ..structures import NonNull | ||
from ..scalars import String | ||
|
||
|
||
def test_argument(): | ||
arg = Argument(String, default_value='a', description='desc', name='b') | ||
assert arg.type == String | ||
assert arg.default_value == 'a' | ||
assert arg.description == 'desc' | ||
assert arg.name == 'b' | ||
|
||
|
||
def test_argument_comparasion(): | ||
arg1 = Argument(String, name='Hey', description='Desc', default_value='default') | ||
arg2 = Argument(String, name='Hey', description='Desc', default_value='default') | ||
|
||
assert arg1 == arg2 | ||
assert arg1 != String() | ||
|
||
|
||
def test_argument_required(): | ||
arg = Argument(String, required=True) | ||
assert arg.type == NonNull(String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
from ..structures import List, NonNull | ||
from ..scalars import String | ||
|
||
|
||
def test_list(): | ||
_list = List(String) | ||
assert _list.of_type == String | ||
assert str(_list) == '[String]' | ||
|
||
|
||
def test_nonnull(): | ||
nonnull = NonNull(String) | ||
assert nonnull.of_type == String | ||
assert str(nonnull) == 'String!' | ||
|
||
|
||
def test_list_comparasion(): | ||
list1 = List(String) | ||
list2 = List(String) | ||
list3 = List(None) | ||
|
||
list1_argskwargs = List(String, None, b=True) | ||
list2_argskwargs = List(String, None, b=True) | ||
|
||
assert list1 == list2 | ||
assert list1 != list3 | ||
assert list1_argskwargs == list2_argskwargs | ||
assert list1 != list1_argskwargs | ||
|
||
|
||
def test_nonnull_comparasion(): | ||
nonnull1 = NonNull(String) | ||
nonnull2 = NonNull(String) | ||
nonnull3 = NonNull(None) | ||
|
||
nonnull1_argskwargs = NonNull(String, None, b=True) | ||
nonnull2_argskwargs = NonNull(String, None, b=True) | ||
|
||
assert nonnull1 == nonnull2 | ||
assert nonnull1 != nonnull3 | ||
assert nonnull1_argskwargs == nonnull2_argskwargs | ||
assert nonnull1 != nonnull1_argskwargs |