def matches_when_submatchers_all_match():
    matcher = all_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )

    assert_equal(matched(), matcher.match(User("bob", "*****@*****.**")))
示例#2
0
def test_when_resolution_raises_graph_error_then_result_is_invalid():
    Root = g.ObjectType("Root", fields=(
        g.field("value", g.String),
    ))

    root_resolver = g.root_object_resolver(Root)

    @root_resolver.field(Root.fields.value)
    def root_resolve_value(graph, query, args):
        raise g.GraphError("BAD")

    graph_definition = g.define_graph(resolvers=(root_resolver, ))
    graph = graph_definition.create_graph({})

    query = """
        query {
            value
        }
    """

    result = graphql.execute(graph=graph, document_text=query, query_type=Root)

    assert_that(result, is_invalid(errors=contains_exactly(
        all_of(
            is_instance(GraphQLError),
            has_str("BAD"),
        ),
    )))
示例#3
0
def is_graphql_argument(type=None):
    if type is None:
        type = anything

    return all_of(
        is_instance(graphql.GraphQLArgument),
        has_attrs(type=type),
    )
def mismatches_when_submatcher_mismatches():
    matcher = all_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )

    assert_equal(unmatched("was missing attribute username"),
                 matcher.match("bobbity"))
def description_contains_descriptions_of_submatchers():
    matcher = all_of(
        has_attr("username", equal_to("bob")),
        has_attr("email_address", equal_to("*****@*****.**")),
    )

    assert_equal(
        "all of:\n * object with attribute username: '******'\n * object with attribute email_address: '*****@*****.**'",
        matcher.describe())
示例#6
0
def is_graphql_interface_type(name, fields=None):
    if fields is None:
        fields = anything

    return all_of(
        is_instance(graphql.GraphQLInterfaceType),
        has_attrs(
            name=name,
            fields=fields,
        ),
    )
示例#7
0
def is_graphql_field(type=None, args=None):
    if type is None:
        type = anything

    if args is None:
        args = anything

    return all_of(
        is_instance(graphql.GraphQLField),
        has_attrs(type=type, args=args),
    )
示例#8
0
def is_graphql_input_object_type(name=None, fields=None):
    if name is None:
        name = anything
    if fields is None:
        fields = anything

    return all_of(
        is_instance(graphql.GraphQLInputObjectType),
        has_attrs(
            name=name,
            fields=fields,
        ),
    )
示例#9
0
def is_graphql_object_type(name=None, fields=None, interfaces=None):
    if name is None:
        name = anything

    if fields is None:
        fields = anything

    if interfaces is None:
        interfaces = anything

    return all_of(
        is_instance(graphql.GraphQLObjectType),
        has_attrs(
            name=name,
            fields=fields,
            interfaces=interfaces,
        ),
    )
示例#10
0
def is_literal_block(**kwargs):
    return all_of(
        is_instance(rst.LiteralBlock),
        has_attrs(**kwargs),
    )
示例#11
0
def is_diff(**kwargs):
    return all_of(
        is_instance(parser.Diff),
        has_attrs(**kwargs),
    )
示例#12
0
def is_diffdoc_block(arguments, options, content):
    return all_of(
        is_instance(rst.DiffdocBlock),
        has_attrs(arguments=arguments, options=options, content=content),
    )
示例#13
0
def _is_in_range(max_value):
    return all_of(is_instance(int), less_than_or_equal_to(max_value))
示例#14
0
def is_text(value):
    return all_of(
        instance_of(documents.Text),
        has_attrs(value=value),
    )
示例#15
0
def is_graphql_enum_type(name, values):
    return all_of(
        is_instance(graphql.GraphQLEnumType),
        has_attrs(name=name, values=values),
    )
示例#16
0
def is_graphql_argument(type):
    return all_of(
        is_instance(graphql.GraphQLArgument),
        has_attrs(type=type),
    )
示例#17
0
def is_start(**kwargs):
    return all_of(
        is_instance(parser.Start),
        has_attrs(**kwargs),
    )
示例#18
0
def is_replace(**kwargs):
    return all_of(
        is_instance(parser.Replace),
        has_attrs(**kwargs),
    )
示例#19
0
def is_graphql_input_field(type):
    return all_of(
        is_instance(graphql.GraphQLInputField),
        has_attrs(type=type),
    )
示例#20
0
def is_graphql_enum_value(value):
    return all_of(
        is_instance(graphql.GraphQLEnumValue),
        has_attrs(value=value),
    )
示例#21
0
def is_output(**kwargs):
    return all_of(
        is_instance(parser.Output),
        has_attrs(**kwargs),
    )
示例#22
0
def is_render(**kwargs):
    return all_of(
        is_instance(parser.Render),
        has_attrs(**kwargs),
    )
示例#23
0
 def matcher(**kwargs):
     return all_of(
         instance_of(element_type),
         has_attrs(**kwargs),
     )
示例#24
0
def is_code_block(**kwargs):
    return all_of(
        is_instance(rst.CodeBlock),
        has_attrs(**kwargs),
    )
示例#25
0
def is_graphql_list(element_matcher):
    return all_of(
        is_instance(graphql.GraphQLList),
        has_attrs(of_type=element_matcher),
    )
示例#26
0
def is_text(text):
    return all_of(
        is_instance(rst.Text),
        has_attrs(text=text),
    )
示例#27
0
def is_graphql_non_null(element_matcher):
    return all_of(
        is_instance(graphql.GraphQLNonNull),
        has_attrs(of_type=element_matcher),
    )