fix: black

This commit is contained in:
Cameron Hurst 2021-03-01 08:53:16 -05:00
parent 322f37196d
commit 51b281d04c
3 changed files with 48 additions and 13 deletions

View File

@ -8,7 +8,9 @@ from snapshottest import Snapshot
snapshots = Snapshot() snapshots = Snapshot()
snapshots["test_correctly_fetches_id_name_rebels 1"] = { snapshots["test_correctly_fetches_id_name_rebels 1"] = {
"data": {"rebels": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}} "data": {
"rebels": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
}
} }
snapshots["test_correctly_refetches_rebels 1"] = { snapshots["test_correctly_refetches_rebels 1"] = {
@ -19,9 +21,13 @@ snapshots["test_correctly_fetches_id_name_empire 1"] = {
"data": {"empire": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}} "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_xwing 1"] = {"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}} snapshots["test_correctly_refetches_xwing 1"] = {
"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
}
snapshots[ snapshots[
"test_str_schema 1" "test_str_schema 1"

View File

@ -128,7 +128,9 @@ def test_query_interface():
executed = hello_schema.execute("{ interfaces { __typename } }") executed = hello_schema.execute("{ interfaces { __typename } }")
assert not executed.errors assert not executed.errors
assert executed.data == {"interfaces": [{"__typename": "One"}, {"__typename": "Two"}]} assert executed.data == {
"interfaces": [{"__typename": "One"}, {"__typename": "Two"}]
}
def test_query_dynamic(): def test_query_dynamic():
@ -177,7 +179,10 @@ def test_query_wrong_default_value():
executed = hello_schema.execute("{ hello { field } }") executed = hello_schema.execute("{ hello { field } }")
assert len(executed.errors) == 1 assert len(executed.errors) == 1
assert executed.errors[0].message == GraphQLError("Expected value of type 'MyType' but got: 'hello'.").message assert (
executed.errors[0].message
== GraphQLError("Expected value of type 'MyType' but got: 'hello'.").message
)
assert executed.data == {"hello": None} assert executed.data == {"hello": None}
@ -259,9 +264,13 @@ def test_query_input_field():
assert not result.errors assert not result.errors
assert result.data == {"test": '["Source!",{"a_input":{"a_field":"String!"}}]'} assert result.data == {"test": '["Source!",{"a_input":{"a_field":"String!"}}]'}
result = test_schema.execute('{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!") result = test_schema.execute(
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
)
assert not result.errors assert not result.errors
assert result.data == {"test": '["Source!",{"a_input":{"recursive_field":{"a_field":"String!"}}}]'} assert result.data == {
"test": '["Source!",{"a_input":{"recursive_field":{"a_field":"String!"}}}]'
}
def test_query_middlewares(): def test_query_middlewares():
@ -280,7 +289,9 @@ def test_query_middlewares():
hello_schema = Schema(Query) hello_schema = Schema(Query)
executed = hello_schema.execute("{ hello, other }", middleware=[reversed_middleware]) executed = hello_schema.execute(
"{ hello, other }", middleware=[reversed_middleware]
)
assert not executed.errors assert not executed.errors
assert executed.data == {"hello": "dlroW", "other": "rehto"} assert executed.data == {"hello": "dlroW", "other": "rehto"}
@ -386,7 +397,11 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
big_list_query = partial(hello_schema.execute, "{ allContainers { x, y, z, o } }") big_list_query = partial(hello_schema.execute, "{ allContainers { x, y, z, o } }")
result = benchmark(big_list_query) result = benchmark(big_list_query)
assert not result.errors assert not result.errors
assert result.data == {"allContainers": [{"x": c.x, "y": c.y, "z": c.z, "o": c.o} for c in big_container_list]} assert result.data == {
"allContainers": [
{"x": c.x, "y": c.y, "z": c.z, "o": c.o} for c in big_container_list
]
}
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark( def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
@ -423,7 +438,11 @@ def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark
big_list_query = partial(hello_schema.execute, "{ allContainers { x, y, z, o } }") big_list_query = partial(hello_schema.execute, "{ allContainers { x, y, z, o } }")
result = benchmark(big_list_query) result = benchmark(big_list_query)
assert not result.errors assert not result.errors
assert result.data == {"allContainers": [{"x": c.x, "y": c.y, "z": c.z, "o": c.o} for c in big_container_list]} assert result.data == {
"allContainers": [
{"x": c.x, "y": c.y, "z": c.z, "o": c.o} for c in big_container_list
]
}
def test_query_annotated_resolvers(): def test_query_annotated_resolvers():

View File

@ -52,7 +52,9 @@ def test_enum():
assert graphql_enum.name == "MyEnum" assert graphql_enum.name == "MyEnum"
assert graphql_enum.description == "Description" assert graphql_enum.description == "Description"
assert graphql_enum.values == { assert graphql_enum.values == {
"foo": GraphQLEnumValue(value=1, description="Description foo=1", deprecation_reason="Is deprecated"), "foo": GraphQLEnumValue(
value=1, description="Description foo=1", deprecation_reason="Is deprecated"
),
"bar": GraphQLEnumValue(value=2, description="Description bar=2"), "bar": GraphQLEnumValue(value=2, description="Description bar=2"),
} }
@ -226,7 +228,11 @@ def test_objecttype_camelcase():
assert list(fields) == ["fooBar"] assert list(fields) == ["fooBar"]
foo_field = fields["fooBar"] foo_field = fields["fooBar"]
assert isinstance(foo_field, GraphQLField) assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {"barFoo": GraphQLArgument(GraphQLString, default_value=Undefined, out_name="bar_foo")} assert foo_field.args == {
"barFoo": GraphQLArgument(
GraphQLString, default_value=Undefined, out_name="bar_foo"
)
}
def test_objecttype_camelcase_disabled(): def test_objecttype_camelcase_disabled():
@ -246,7 +252,11 @@ def test_objecttype_camelcase_disabled():
assert list(fields) == ["foo_bar"] assert list(fields) == ["foo_bar"]
foo_field = fields["foo_bar"] foo_field = fields["foo_bar"]
assert isinstance(foo_field, GraphQLField) assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {"bar_foo": GraphQLArgument(GraphQLString, default_value=Undefined, out_name="bar_foo")} assert foo_field.args == {
"bar_foo": GraphQLArgument(
GraphQLString, default_value=Undefined, out_name="bar_foo"
)
}
def test_objecttype_with_possible_types(): def test_objecttype_with_possible_types():