repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
graphql-python/graphene | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
def test_node_field_only_lazy_type_wrong():
executed = schema.execute(
'{ onlyNodeLazy(id:"%s") { __typename, name } } '
% Node.to_global_i... | {"onlyNodeLazy": None} | assert | collection | graphene/relay/tests/test_node.py | test_node_field_only_lazy_type_wrong | 170 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_string():
assert String.serialize("string") == "string"
assert String.serialize(1) == "1"
assert String.serialize(-1.1) == "-1.1"
assert String.serialize(True) == | "true" | assert | string_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_string | 40 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..scalars import String
from ..structures import List, NonNull
from .utils import MyLazyType
def test_list_comparasion():
list1 = List(String)
list2 = List(String)
list3 = List(None)
list1_argskwargs = List(String, None, b=True)
list2_... | list2 | assert | variable | graphene/types/tests/test_structures.py | test_list_comparasion | 112 | null | |
graphql-python/graphene | import re
from pytest import raises
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
from ..connection import (
Connection,
ConnectionField,
PageInfo,
ConnectionOptions,
get_edge_class,
)
from ..node import Node
def test_connection_extra_abstract_fields():
... | MyObject | assert | variable | graphene/relay/tests/test_connection.py | test_connection_extra_abstract_fields | 108 | null | |
graphql-python/graphene | from ..generic import GenericScalar
from ..objecttype import ObjectType
from ..schema import Schema
def test_generic_query_variable():
for generic_value in [
1,
1.1,
True,
"str",
[1, 2, 3],
[1.1, 2.2, 3.3],
[True, False],
["str1", "str2"],
{"k... | {"generic": generic_value} | assert | collection | graphene/types/tests/test_generic.py | test_generic_query_variable | 45 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def return_input(_parent, _info, input):
return input
class TestFloat:
def test_optional_input(s... | {"optional": {"float": None}} | assert | collection | graphene/types/tests/test_scalar.py | test_optional_input | TestFloat | 164 | null |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_basic():
MyType = object()
args = {"my arg": Argument(True)}
def resolver():
... | "name" | assert | string_literal | graphene/types/tests/test_field.py | test_field_basic | 39 | null | |
graphql-python/graphene | import re
from uuid import uuid4
from graphql import graphql_sync
from ..id_type import BaseGlobalIDType, SimpleGlobalIDType, UUIDGlobalIDType
from ..node import Node
from ...types import Int, ObjectType, Schema, String
class TestUUIDGlobalID:
def setup_method(self):
self.user_list = [
{"id":... | types | assert | variable | graphene/relay/tests/test_custom_global_id.py | test_str_schema_correct | TestUUIDGlobalID | 49 | null |
graphql-python/graphene | from asyncio import gather
from collections import namedtuple
from functools import partial
from unittest.mock import Mock
from graphene.utils.dataloader import DataLoader
from pytest import mark, raises
from graphene import ObjectType, String, Schema, Field, List
CHARACTERS = {
"1": {"name": "Luke Skywalker", "... | [] | assert | collection | graphene/utils/tests/test_dataloader.py | test_supports_loading_multiple_keys_in_one_call | 144 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_int():
assert Int.serialize(1) == 1
assert Int.serialize(0) == | 0 | assert | numeric_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_int | 7 | null | |
graphql-python/graphene | from ..resolver import (
attr_resolver,
dict_resolver,
dict_or_attr_resolver,
get_default_resolver,
set_default_resolver,
)
args = {}
context = None
info = None
demo_dict = {"attr": "value"}
def test_attr_resolver_default_value():
resolved = attr_resolver("attr2", "default", demo_obj, info, *... | "default" | assert | string_literal | graphene/types/tests/test_resolver.py | test_attr_resolver_default_value | 27 | null | |
graphql-python/graphene | from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..unmountedtype import UnmountedType
def test_generate_interface_inherit_abstracttype():
class MyAbstractType:
field1 = MyScalar()
class MyInter... | ["field1", "field2"] | assert | collection | graphene/types/tests/test_interface.py | test_generate_interface_inherit_abstracttype | 74 | null | |
graphql-python/graphene | import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from ..context import Context
from ..dynamic import Dynamic
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputOb... | {"info": "base-info"} | assert | collection | graphene/types/tests/test_query.py | test_query_annotated_resolvers | 479 | null | |
graphql-python/graphene | import copy
from ..argument import Argument
from ..definitions import GrapheneGraphQLType
from ..enum import Enum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import Boole... | "[Int]" | assert | string_literal | graphene/types/tests/test_definition.py | test_stringifies_simple_types | 224 | null | |
graphql-python/graphene | from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
def test_mutation_raises_exception_if_... | str(excinfo.value) | assert | func_call | graphene/types/tests/test_mutation.py | test_mutation_raises_exception_if_no_mutate | 54 | null | |
graphql-python/graphene | import re
from uuid import uuid4
from graphql import graphql_sync
from ..id_type import BaseGlobalIDType, SimpleGlobalIDType, UUIDGlobalIDType
from ..node import Node
from ...types import Int, ObjectType, Schema, String
class TestIncompleteCustomGlobalID:
def setup_method(self):
self.user_list = [
... | None | assert | none_literal | graphene/relay/tests/test_custom_global_id.py | test_must_define_to_global_id | TestIncompleteCustomGlobalID | 280 | null |
graphql-python/graphene | from ..orderedtype import OrderedType
def test_orderedtype_eq():
one = OrderedType()
two = OrderedType()
assert one == | one | assert | variable | graphene/utils/tests/test_orderedtype.py | test_orderedtype_eq | 16 | null | |
graphql-python/graphene | import graphene
def test_issue():
query_string = """
query myQuery {
someField(from: "Oh")
}
"""
schema = graphene.Schema(query=Query)
result = schema.execute(query_string)
assert not result.errors
assert result.data["someField"] == | "Oh" | assert | string_literal | graphene/tests/issues/test_490.py | test_issue | 24 | null | |
graphql-python/graphene | from pytest import mark, raises
from ...types import (
ID,
Argument,
Field,
InputField,
InputObjectType,
NonNull,
ObjectType,
Schema,
)
from ...types.scalars import String
from ..mutation import ClientIDMutation
def test_mutation():
fields = SaySomething._meta.fields
assert lis... | String | assert | variable | graphene/relay/tests/test_mutation.py | test_mutation | 131 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_default_value_not_callable():
MyType = object()
try:
Field(MyType, default_value... | str(e) | assert | func_call | graphene/types/tests/test_field.py | test_field_default_value_not_callable | 60 | null | |
graphql-python/graphene | import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from ..context import Context
from ..dynamic import Dynamic
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputOb... | {"ship": {"name": "xwing"}} | assert | collection | graphene/types/tests/test_query.py | test_objecttype_on_instances | 320 | null | |
graphql-python/graphene | from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
def test_special_objecttype_inherit_meta_options():
class MyType(SpecialObjectType):
pass
assert MyType._meta.name == | "MyType" | assert | string_literal | graphene/tests/issues/test_425.py | test_special_objecttype_inherit_meta_options | 43 | null | |
graphql-python/graphene | import pickle
from ...types.enum import Enum
def test_enums_pickling():
a = PickleEnum.A
pickled = pickle.dumps(a)
restored = pickle.loads(pickled)
assert type(a) is | type(restored) | assert | func_call | graphene/tests/issues/test_881.py | test_enums_pickling | 16 | null | |
graphql-python/graphene | import copy
from ..argument import Argument
from ..definitions import GrapheneGraphQLType
from ..enum import Enum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import Boole... | "Int!" | assert | string_literal | graphene/types/tests/test_definition.py | test_stringifies_simple_types | 223 | null | |
graphql-python/graphene | from textwrap import dedent
from ..argument import Argument
from ..enum import Enum, PyEnum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..mutation import Mutation
from ..scalars import String
from ..schema import ObjectType, Schema
def test_enum_can... | RGB.RED | assert | complex_expr | graphene/types/tests/test_enum.py | test_enum_can_be_initialized | 201 | null | |
graphql-python/graphene | from pytest import raises
from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..unmountedtype import UnmountedType
def test_generate_objecttype_inherit_abstracttype():
class M... | () | assert | collection | graphene/types/tests/test_objecttype.py | test_generate_objecttype_inherit_abstracttype | 120 | null | |
graphql-python/graphene | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
def test_node_field_args():
field_args = {
"name": "my_custom_name",
"description": "my_custom_description",
"deprecation_reason": ... | value | assert | variable | graphene/relay/tests/test_node.py | test_node_field_args | 133 | null | |
graphql-python/graphene | from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
def test_special_objecttype_could_be_subclassed():
class MyType(SpecialObjectType):
class Meta:
other_attr = "yeah!"
... | "yeah!" | assert | string_literal | graphene/tests/issues/test_425.py | test_special_objecttype_could_be_subclassed | 29 | null | |
graphql-python/graphene | from pytest import mark, raises
from ...types import (
ID,
Argument,
Field,
InputField,
InputObjectType,
NonNull,
ObjectType,
Schema,
)
from ...types.scalars import String
from ..mutation import ClientIDMutation
def test_mutation():
fields = SaySomething._meta.fields
assert lis... | SaySomething.Input | assert | complex_expr | graphene/relay/tests/test_mutation.py | test_mutation | 128 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_source_as_argument():
MyType = object()
field = Field(MyType, source=String())
asse... | field.args | assert | complex_expr | graphene/types/tests/test_field.py | test_field_source_as_argument | 118 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument, to_arguments
from ..field import Field
from ..inputfield import InputField
from ..scalars import String
from ..structures import NonNull
def test_argument_comparasion():
arg1 = Argument(
String,
name="Hey",
... | arg2 | assert | variable | graphene/types/tests/test_argument.py | test_argument_comparasion | 36 | null | |
graphql-python/graphene | from ..str_converters import to_camel_case, to_snake_case
def test_camel_case():
assert to_camel_case("snakes_on_a_plane") == "snakesOnAPlane"
assert to_camel_case("snakes_on_a__plane") == "snakesOnA_Plane"
assert to_camel_case("i_phone_hysteria") == "iPhoneHysteria"
assert to_camel_case("field_i18n")... | "fieldI18n" | assert | string_literal | graphene/utils/tests/test_str_converters.py | test_camel_case | 19 | null | |
graphql-python/graphene | from textwrap import dedent
from ..argument import Argument
from ..enum import Enum, PyEnum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..mutation import Mutation
from ..scalars import String
from ..schema import ObjectType, Schema
def test_enum_val... | RGB | assert | variable | graphene/types/tests/test_enum.py | test_enum_value_as_unmounted_field | 157 | null | |
graphql-python/graphene | from ..base import BaseOptions, BaseType
def test_basetype():
class MyBaseType(CustomType):
pass
assert isinstance(MyBaseType._meta, CustomOptions)
assert MyBaseType._meta.name == "MyBaseType"
assert MyBaseType._meta.description is | None | assert | none_literal | graphene/types/tests/test_base.py | test_basetype | 21 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..scalars import String
from ..structures import List, NonNull
from .utils import MyLazyType
def test_list_comparasion():
list1 = List(String)
list2 = List(String)
list3 = List(None)
list1_argskwargs = List(String, None, b=True)
list2_... | list3 | assert | variable | graphene/types/tests/test_structures.py | test_list_comparasion | 113 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def return_input(_parent, _info, input):
return input
class TestFloat:
def test_query(self):
... | {"optional": {"float": 20.0}} | assert | collection | graphene/types/tests/test_scalar.py | test_query | TestFloat | 152 | null |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_source_argument_as_kw():
MyType = object()
deprecation_reason = "deprecated"
field =... | True | assert | bool_literal | graphene/types/tests/test_field.py | test_field_source_argument_as_kw | 141 | null | |
graphql-python/graphene | from graphql import Undefined
from ..argument import Argument
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..objecttype import ObjectType
from ..scalars import Boolean, String
from ..schema import Schema
from ..unmountedtype import UnmountedType
from ... | ["field1", "field2"] | assert | collection | graphene/types/tests/test_inputobjecttype.py | test_generate_inputobjecttype_inherit_abstracttype | 90 | null | |
graphql-python/graphene | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
def test_node_field_only_type_wrong():
executed = schema.execute(
'{ onlyNode(id:"%s") { __typename, name } } '
% Node.to_global_id("MyOthe... | 1 | assert | numeric_literal | graphene/relay/tests/test_node.py | test_node_field_only_type_wrong | 149 | null | |
graphql-python/graphene | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
def test_node_query():
executed = schema.execute(
'{ node(id:"%s") { ... on MyNode { name } } }' % Node.to_global_id("MyNode", 1)
)
assert ... | {"node": {"name": "1"}} | assert | collection | graphene/relay/tests/test_node.py | test_node_query | 65 | null | |
graphql-python/graphene | import datetime
from graphql import GraphQLError
from pytest import fixture
from ..datetime import Date, DateTime, Time
from ..objecttype import ObjectType
from ..schema import Schema
def sample_datetime():
utc_datetime = datetime.datetime(2019, 5, 25, 5, 30, 15, 10, datetime.timezone.utc)
return utc_dateti... | 1 | assert | numeric_literal | graphene/types/tests/test_datetime.py | _test_bad_variables | 249 | null | |
graphql-python/graphene | from pytest import raises
from ..field import Field
from ..objecttype import ObjectType
from ..union import Union
from ..unmountedtype import UnmountedType
def test_generate_union():
class MyUnion(Union):
"""Documentation"""
class Meta:
types = (MyObjectType1, MyObjectType2)
ass... | "MyUnion" | assert | string_literal | graphene/types/tests/test_union.py | test_generate_union | 24 | null | |
graphql-python/graphene | import decimal
from ..decimal import Decimal
from ..objecttype import ObjectType
from ..schema import Schema
def test_bad_decimal_query():
not_a_decimal = "Nobody expects the Spanish Inquisition!"
result = schema.execute("""{ decimal(input: "%s") }""" % not_a_decimal)
assert result.errors
assert len... | 1 | assert | numeric_literal | graphene/types/tests/test_decimal.py | test_bad_decimal_query | 43 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_int():
assert Int.serialize(1) == | 1 | assert | numeric_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_int | 6 | null | |
graphql-python/graphene | from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
def test_mutation_no_fields_output():
... | {"createUser": {"name": None}} | assert | collection | graphene/types/tests/test_mutation.py | test_mutation_no_fields_output | 134 | null | |
graphql-python/graphene | from asyncio import gather
from collections import namedtuple
from functools import partial
from unittest.mock import Mock
from graphene.utils.dataloader import DataLoader
from pytest import mark, raises
from graphene import ObjectType, String, Schema, Field, List
CHARACTERS = {
"1": {"name": "Luke Skywalker", "... | "A" | assert | string_literal | graphene/utils/tests/test_dataloader.py | test_caches_repeated_requests | 207 | null | |
graphql-python/graphene | from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
def test_special_enum_inherit_meta_options():
class MyEnum(SpecialEnum):
pass
assert MyEnum._meta.name == | "MyEnum" | assert | string_literal | graphene/tests/issues/test_425.py | test_special_enum_inherit_meta_options | 117 | null | |
graphql-python/graphene | from graphql import Undefined
from ..argument import Argument
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..objecttype import ObjectType
from ..scalars import Boolean, String
from ..schema import Schema
from ..unmountedtype import UnmountedType
from ... | {"isChild": True} | assert | collection | graphene/types/tests/test_inputobjecttype.py | test_inputobjecttype_of_input | 141 | null | |
graphql-python/graphene | from graphene.test import Client
from ..data import setup
from ..schema import schema
setup()
client = Client(schema)
def test_invalid_id_query():
result = client.execute(
"""
query humanQuery($id: String!) {
human(id: $id) {
name
}
}
""",
vari... | {"data": {"human": None}} | assert | collection | examples/starwars/tests/test_query.py | test_invalid_id_query | 154 | null | |
graphql-python/graphene | import re
from pytest import raises
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
from ..connection import (
Connection,
ConnectionField,
PageInfo,
ConnectionOptions,
get_edge_class,
)
from ..node import Node
def test_connection():
class MyObjectConnecti... | PageInfo | assert | variable | graphene/relay/tests/test_connection.py | test_connection | 46 | null | |
graphql-python/graphene | from graphql import Undefined
from ..argument import Argument
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..objecttype import ObjectType
from ..scalars import Boolean, String
from ..schema import Schema
from ..unmountedtype import UnmountedType
from ... | ["b", "a", "field", "asa"] | assert | collection | graphene/types/tests/test_inputobjecttype.py | test_ordered_fields_in_inputobjecttype | 56 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def test_ints():
assert Int.parse_value(2**31 - 1) is not Undefined
assert Int.parse_value("2.0") ... | 2**31 | assert | complex_expr | graphene/types/tests/test_scalar.py | test_ints | 32 | null | |
graphql-python/graphene | from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
def test_special_objecttype_inherit_meta_options():
class MyType(SpecialObjectType):
pass
assert MyType._meta.name == "MyType... | None | assert | none_literal | graphene/tests/issues/test_425.py | test_special_objecttype_inherit_meta_options | 44 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_string():
assert String.serialize("string") == "string"
assert String.serialize(1) == "1"
assert String.serialize(-1.1) == "-1.1"
assert String.serialize(True) == "true"
assert String.seriali... | "false" | assert | string_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_string | 41 | null | |
graphql-python/graphene | import base64
from graphql import GraphQLError
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..base64 import Base64
def test_base64_query_none():
result = schema.execute("""{ base64 }""")
assert not result.errors
assert result.data == | {"base64": None} | assert | collection | graphene/types/tests/test_base64.py | test_base64_query_none | 63 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_string():
assert String.serialize("string") == "string"
assert String.serialize(1) == | "1" | assert | string_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_string | 38 | null | |
graphql-python/graphene | from asyncio import gather
from collections import namedtuple
from functools import partial
from unittest.mock import Mock
from graphene.utils.dataloader import DataLoader
from pytest import mark, raises
from graphene import ObjectType, String, Schema, Field, List
CHARACTERS = {
"1": {"name": "Luke Skywalker", "... | "C" | assert | string_literal | graphene/utils/tests/test_dataloader.py | test_caches_repeated_requests | 215 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_source_as_argument():
MyType = object()
field = Field(MyType, source=String())
asser... | String | assert | variable | graphene/types/tests/test_field.py | test_field_source_as_argument | 119 | null | |
graphql-python/graphene | import copy
from ..argument import Argument
from ..definitions import GrapheneGraphQLType
from ..enum import Enum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import Boole... | "[Int]!" | assert | string_literal | graphene/types/tests/test_definition.py | test_stringifies_simple_types | 225 | null | |
graphql-python/graphene | import datetime
from graphql import GraphQLError
from pytest import fixture
from ..datetime import Date, DateTime, Time
from ..objecttype import ObjectType
from ..schema import Schema
def sample_datetime():
utc_datetime = datetime.datetime(2019, 5, 25, 5, 30, 15, 10, datetime.timezone.utc)
return utc_dateti... | {"date": isoformat} | assert | collection | graphene/types/tests/test_datetime.py | test_date_query | 84 | null | |
graphql-python/graphene | from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..unmountedtype import UnmountedType
def test_ordered_fields_in_interface():
class MyInterface(Interface):
b = Field(MyType)
a = Field(MyType... | ["b", "a", "field", "asa"] | assert | collection | graphene/types/tests/test_interface.py | test_ordered_fields_in_interface | 56 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def return_input(_parent, _info, input):
return input
class TestFloat:
def test_query(self):
... | {"optional": {"float": 20.2}} | assert | collection | graphene/types/tests/test_scalar.py | test_query | TestFloat | 156 | null |
graphql-python/graphene | import re
from textwrap import dedent
from graphql_relay import to_global_id
from ...types import ObjectType, Schema, String
from ..node import Node, is_node
def test_node_field_custom():
node_field = Node.Field(MyNode)
assert node_field.type == | MyNode | assert | variable | graphene/relay/tests/test_node.py | test_node_field_custom | 121 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..scalars import String
from ..structures import List, NonNull
from .utils import MyLazyType
def test_list():
_list = List(String)
assert _list.of_type == | String | assert | variable | graphene/types/tests/test_structures.py | test_list | 12 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def test_ints():
assert Int.parse_value(2**31 - 1) is not Undefined
assert Int.parse_value("2.0")... | 2 | assert | numeric_literal | graphene/types/tests/test_scalar.py | test_ints | 18 | null | |
graphql-python/graphene | import graphene
def test_create_post():
query_string = """
mutation {
createPost(text: "Try this out") {
result {
__typename
}
}
}
"""
schema = graphene.Schema(query=Query, mutation=Mutations)
result = schema.execute(query_string)
assert not result.er... | "Success" | assert | string_literal | graphene/tests/issues/test_313.py | test_create_post | 57 | null | |
graphql-python/graphene | import re
from pytest import raises
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
from ..connection import (
Connection,
ConnectionField,
PageInfo,
ConnectionOptions,
get_edge_class,
)
from ..node import Node
def test_connection_override_fields():
class ... | ["page_info", "edges"] | assert | collection | graphene/relay/tests/test_connection.py | test_connection_override_fields | 150 | null | |
graphql-python/graphene | from textwrap import dedent
from ..argument import Argument
from ..enum import Enum, PyEnum
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputObjectType
from ..mutation import Mutation
from ..scalars import String
from ..schema import ObjectType, Schema
def test_hashable... | "b" | assert | string_literal | graphene/types/tests/test_enum.py | test_hashable_enum | 549 | null | |
graphql-python/graphene | import base64
from graphql import GraphQLError
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..base64 import Base64
def test_base64_query_invalid():
bad_inputs = [dict(), 123, "This is not valid base64"]
for input_ in bad_inputs:
result = schema.ex... | 1 | assert | numeric_literal | graphene/types/tests/test_base64.py | test_base64_query_invalid | 74 | null | |
graphql-python/graphene | from pytest import raises
from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..unmountedtype import UnmountedType
def test_objecttype_as_container_only_args():
container = Co... | "2" | assert | string_literal | graphene/types/tests/test_objecttype.py | test_objecttype_as_container_only_args | 159 | null | |
graphql-python/graphene | from graphql import Undefined
from graphql.type import (
GraphQLArgument,
GraphQLEnumType,
GraphQLEnumValue,
GraphQLField,
GraphQLInputField,
GraphQLInputObjectType,
GraphQLInterfaceType,
GraphQLNonNull,
GraphQLObjectType,
GraphQLString,
)
from ..dynamic import Dynamic
from ..en... | "x" | assert | string_literal | graphene/types/tests/test_type_map.py | test_required_argument_with_default_value | 109 | null | |
graphql-python/graphene | import re
from uuid import uuid4
from graphql import graphql_sync
from ..id_type import BaseGlobalIDType, SimpleGlobalIDType, UUIDGlobalIDType
from ..node import Node
from ...types import Int, ObjectType, Schema, String
class TestIncompleteCustomGlobalID:
def setup_method(self):
self.user_list = [
... | ["user", "id"] | assert | collection | graphene/relay/tests/test_custom_global_id.py | test_must_define_to_global_id | TestIncompleteCustomGlobalID | 282 | null |
graphql-python/graphene | from textwrap import dedent
from pytest import raises
from graphql.type import GraphQLObjectType, GraphQLSchema
from ..field import Field
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
def test_schema():
schema = Schema(Query)
graphql_schema = schema.graphql_sch... | "Query" | assert | string_literal | graphene/types/tests/test_schema.py | test_schema | 27 | null | |
graphql-python/graphene | from pytest import raises
from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..unmountedtype import UnmountedType
def test_generate_objecttype_with_private_attributes():
clas... | "custom" | assert | string_literal | graphene/types/tests/test_objecttype.py | test_generate_objecttype_with_private_attributes | 96 | null | |
graphql-python/graphene | from pytest import mark, raises
from ...types import (
ID,
Argument,
Field,
InputField,
InputObjectType,
NonNull,
ObjectType,
Schema,
)
from ...types.scalars import String
from ..mutation import ClientIDMutation
def test_subclassed_mutation():
fields = OtherMutation._meta.fields
... | OtherMutation.Input | assert | complex_expr | graphene/relay/tests/test_mutation.py | test_subclassed_mutation | 154 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument, to_arguments
from ..field import Field
from ..inputfield import InputField
from ..scalars import String
from ..structures import NonNull
def test_argument_required():
arg = Argument(String, required=True)
assert arg.typ... | NonNull(String) | assert | func_call | graphene/types/tests/test_argument.py | test_argument_required | 42 | null | |
graphql-python/graphene | import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from ..context import Context
from ..dynamic import Dynamic
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputOb... | {"annotated": "base-self"} | assert | collection | graphene/types/tests/test_query.py | test_query_annotated_resolvers | 471 | null | |
graphql-python/graphene | from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..unmountedtype import UnmountedType
def test_generate_interface_inherit_abstracttype():
class MyAbstractType:
field1 = MyScalar()
class MyInter... | [Field, Field] | assert | collection | graphene/types/tests/test_interface.py | test_generate_interface_inherit_abstracttype | 75 | null | |
graphql-python/graphene | from graphql import Undefined
from graphql.type import (
GraphQLArgument,
GraphQLEnumType,
GraphQLEnumValue,
GraphQLField,
GraphQLInputField,
GraphQLInputObjectType,
GraphQLInterfaceType,
GraphQLNonNull,
GraphQLObjectType,
GraphQLString,
)
from ..dynamic import Dynamic
from ..en... | True | assert | bool_literal | graphene/types/tests/test_type_map.py | test_objecttype_with_possible_types | 302 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_boolean():
assert Boolean.serialize("string") is | True | assert | bool_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_boolean | 46 | null | |
graphql-python/graphene | from ..field import Field
from ..scalars import String
def test_mounted_type():
unmounted = String()
mounted = Field.mounted(unmounted)
assert isinstance(mounted, Field)
assert mounted.type == | String | assert | variable | graphene/types/tests/test_mountedtype.py | test_mounted_type | 15 | null | |
graphql-python/graphene | from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
def test_generate_mutation_with_meta()... | (MyType,) | assert | collection | graphene/types/tests/test_mutation.py | test_generate_mutation_with_meta | 43 | null | |
graphql-python/graphene | from ...types import ObjectType, Schema, String, NonNull
def test_required_input_provided():
"""
Test that a required argument works when provided.
"""
input_value = "Potato"
result = schema.execute('{ hello(input: "%s") }' % input_value)
assert not result.errors
assert result.data == | {"hello": "Hello Potato!"} | assert | collection | graphene/tests/issues/test_1394.py | test_required_input_provided | 23 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..scalars import String
from ..structures import List, NonNull
from .utils import MyLazyType
def test_list_with_lazy_type():
MyType = object()
field = List(lambda: MyType)
assert field.of_type == | MyType | assert | variable | graphene/types/tests/test_structures.py | test_list_with_lazy_type | 29 | null | |
graphql-python/graphene | import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from ..context import Context
from ..dynamic import Dynamic
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputOb... | {"hello": None} | assert | collection | graphene/types/tests/test_query.py | test_query_wrong_default_value | 186 | null | |
graphql-python/graphene | import pickle
from ...types.enum import Enum
def test_enums_pickling():
a = PickleEnum.A
pickled = pickle.dumps(a)
restored = pickle.loads(pickled)
assert type(a) is type(restored)
assert a == restored
assert a.value == restored.value
assert a.name == | restored.name | assert | complex_expr | graphene/tests/issues/test_881.py | test_enums_pickling | 19 | null | |
graphql-python/graphene | import datetime
from graphql import GraphQLError
from pytest import fixture
from ..datetime import Date, DateTime, Time
from ..objecttype import ObjectType
from ..schema import Schema
def sample_datetime():
utc_datetime = datetime.datetime(2019, 5, 25, 5, 30, 15, 10, datetime.timezone.utc)
return utc_dateti... | None | assert | none_literal | graphene/types/tests/test_datetime.py | test_bad_datetime_query | 141 | null | |
graphql-python/graphene | from functools import partial
from ..dynamic import Dynamic
from ..scalars import String
from ..structures import List, NonNull
def test_dynamic():
dynamic = Dynamic(lambda: String)
assert dynamic.get_type() == String
assert str(dynamic.get_type()) == | "String" | assert | string_literal | graphene/types/tests/test_dynamic.py | test_dynamic | 11 | null | |
graphql-python/graphene | from ..field import Field
from ..scalars import String
def test_mounted_type_custom():
unmounted = String(metadata={"hey": "yo!"})
mounted = CustomField.mounted(unmounted)
assert isinstance(mounted, CustomField)
assert mounted.type == String
assert mounted.metadata == | {"hey": "yo!"} | assert | collection | graphene/types/tests/test_mountedtype.py | test_mounted_type_custom | 23 | null | |
graphql-python/graphene | import json
from functools import partial
from graphql import (
GraphQLError,
GraphQLResolveInfo as ResolveInfo,
Source,
execute,
parse,
)
from ..context import Context
from ..dynamic import Dynamic
from ..field import Field
from ..inputfield import InputField
from ..inputobjecttype import InputOb... | {"allInts": list(big_list)} | assert | collection | graphene/types/tests/test_query.py | test_big_list_query_benchmark | 337 | null | |
graphql-python/graphene | from ..objecttype import ObjectType, Field
from ..scalars import Scalar, Int, BigInt, Float, String, Boolean
from ..schema import Schema
from graphql import Undefined
from graphql.language.ast import IntValueNode
def return_input(_parent, _info, input):
return input
class TestInt:
def test_query(self):
... | {"optional": {"int": 20}} | assert | collection | graphene/types/tests/test_scalar.py | test_query | TestInt | 67 | null |
graphql-python/graphene | import decimal
from ..decimal import Decimal
from ..objecttype import ObjectType
from ..schema import Schema
def test_bad_decimal_query():
not_a_decimal = "Nobody expects the Spanish Inquisition!"
result = schema.execute("""{ decimal(input: "%s") }""" % not_a_decimal)
assert result.errors
assert len(... | None | assert | none_literal | graphene/types/tests/test_decimal.py | test_bad_decimal_query | 44 | null | |
graphql-python/graphene | from graphql import Undefined
from ..scalars import Boolean, Float, Int, String
def test_serializes_output_string():
assert String.serialize("string") == | "string" | assert | string_literal | graphene/types/tests/test_scalars_serialization.py | test_serializes_output_string | 37 | null | |
graphql-python/graphene | from ..base import BaseOptions, BaseType
def test_basetype_custom():
class MyBaseType(CustomType):
"""Documentation"""
class Meta:
name = "Base"
description = "Desc"
assert isinstance(MyBaseType._meta, CustomOptions)
assert MyBaseType._meta.name == | "Base" | assert | string_literal | graphene/types/tests/test_base.py | test_basetype_custom | 46 | null | |
graphql-python/graphene | from ..objecttype import ObjectType
from ..schema import Schema
from ..uuid import UUID
from ..structures import NonNull
def test_uuidstring_optional_uuid_input():
"""
Test that we can provide a null value to an optional input
"""
result = schema.execute("{ uuid(input: null) }")
assert not result.e... | {"uuid": None} | assert | collection | graphene/types/tests/test_uuid.py | test_uuidstring_optional_uuid_input | 60 | null | |
graphql-python/graphene | from functools import partial
from pytest import raises
from ..argument import Argument
from ..field import Field
from ..scalars import String
from ..structures import NonNull
from .utils import MyLazyType
def test_field_source():
MyType = object()
field = Field(MyType, source="value")
assert field.reso... | MyInstance.value | assert | complex_expr | graphene/types/tests/test_field.py | test_field_source | 66 | null | |
graphql-python/graphene | from graphene.types.enum import Enum, EnumOptions
from graphene.types.inputobjecttype import InputObjectType
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
def test_special_objecttype_inherit_meta_options():
class MyType(SpecialObjectType):
pass
assert MyType._meta.name == "MyType... | () | assert | collection | graphene/tests/issues/test_425.py | test_special_objecttype_inherit_meta_options | 45 | null | |
graphql-python/graphene | from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
def test_generate_mutation_no_args():
... | {"name": "Peter"} | assert | collection | graphene/types/tests/test_mutation.py | test_generate_mutation_no_args | 28 | null | |
graphql-python/graphene | import graphene
def test_issue():
options = {"description": "This my enum", "deprecation_reason": "For the funs"}
new_enum = graphene.Enum("MyEnum", [("some", "data")], **options)
assert new_enum._meta.description == | options["description"] | assert | complex_expr | graphene/tests/issues/test_956.py | test_issue | 7 | null | |
graphql-python/graphene | from pytest import raises
from ..argument import Argument
from ..dynamic import Dynamic
from ..mutation import Mutation
from ..objecttype import ObjectType
from ..scalars import String
from ..schema import Schema
from ..structures import NonNull
from ..interface import Interface
def test_mutation_custom_output_type()... | "Peter" | assert | string_literal | graphene/types/tests/test_mutation.py | test_mutation_custom_output_type | 75 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.