Fixed tests

This commit is contained in:
Stefano Tabacco 2022-01-06 16:33:17 +11:00
parent 7ecb4e68ba
commit c0a9942248
4 changed files with 44 additions and 21 deletions

View File

@ -7,31 +7,52 @@ from snapshottest import Snapshot
snapshots = Snapshot()
snapshots["test_correctly_fetches_id_name_rebels 1"] = {
"data": {
"rebels": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
snapshots['test_correctly_fetches_id_name_empire 1'] = {
'data': {
'empire': {
'id': 'RmFjdGlvbjoy',
'name': 'Galactic Empire'
}
}
}
snapshots["test_correctly_refetches_rebels 1"] = {
"data": {"node": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}}
snapshots['test_correctly_fetches_id_name_rebels 1'] = {
'data': {
'rebels': {
'id': 'RmFjdGlvbjox',
'name': 'Alliance to Restore the Republic'
}
}
}
snapshots["test_correctly_fetches_id_name_empire 1"] = {
"data": {"empire": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
snapshots['test_correctly_refetches_empire 1'] = {
'data': {
'node': {
'id': 'RmFjdGlvbjoy',
'name': 'Galactic Empire'
}
}
}
snapshots["test_correctly_refetches_empire 1"] = {
"data": {"node": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
snapshots['test_correctly_refetches_rebels 1'] = {
'data': {
'node': {
'id': 'RmFjdGlvbjox',
'name': 'Alliance to Restore the Republic'
}
}
}
snapshots["test_correctly_refetches_xwing 1"] = {
"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
snapshots['test_correctly_refetches_xwing 1'] = {
'data': {
'node': {
'id': 'U2hpcDox',
'name': 'X-Wing'
}
}
}
snapshots[
"test_str_schema 1"
] = '''type Query {
snapshots['test_str_schema 1'] = '''type Query {
rebels: Faction
empire: Faction
node(
@ -49,7 +70,7 @@ type Faction implements Node {
name: String
"""The ships used by the faction."""
ships(before: String = null, after: String = null, first: Int = null, last: Int = null): ShipConnection
ships(before: String, after: String, first: Int, last: Int): ShipConnection
}
"""An object with an ID"""

View File

@ -4,6 +4,7 @@ from .dynamic import Dynamic
from .mountedtype import MountedType
from .structures import NonNull
from .utils import get_type
from graphql import Undefined
class Argument(MountedType):
@ -41,7 +42,7 @@ class Argument(MountedType):
def __init__(
self,
type_,
default_value=None,
default_value=Undefined,
description=None,
name=None,
required=False,

View File

@ -229,11 +229,11 @@ def test_query_arguments():
result = test_schema.execute("{ test }", None)
assert not result.errors
assert result.data == {"test": '[null,{"a_str":null,"a_int":null}]'}
assert result.data == {"test": "[null,{}]"}
result = test_schema.execute('{ test(aStr: "String!") }', "Source!")
assert not result.errors
assert result.data == {"test": '["Source!",{"a_str":"String!","a_int":null}]'}
assert result.data == {"test": '["Source!",{"a_str":"String!"}]'}
result = test_schema.execute('{ test(aInt: -123, aStr: "String!") }', "Source!")
assert not result.errors
@ -243,6 +243,7 @@ def test_query_arguments():
]
def test_query_input_field():
class Input(InputObjectType):
a_field = String()
@ -258,7 +259,7 @@ def test_query_input_field():
result = test_schema.execute("{ test }", None)
assert not result.errors
assert result.data == {"test": '[null,{"a_input":null}]'}
assert result.data == {"test": "[null,{}]"}
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
assert not result.errors

View File

@ -244,7 +244,7 @@ def test_objecttype_camelcase():
foo_field = fields["fooBar"]
assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {
"barFoo": GraphQLArgument(GraphQLString, default_value=None, out_name="bar_foo")
"barFoo": GraphQLArgument(GraphQLString, out_name="bar_foo")
}
@ -267,7 +267,7 @@ def test_objecttype_camelcase_disabled():
assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {
"bar_foo": GraphQLArgument(
GraphQLString, default_value=None, out_name="bar_foo"
GraphQLString, out_name="bar_foo"
)
}