예제 #1
0
def test_ast_from_value_with_non_null_type_and_none():
    typ = GraphQLNonNull(GraphQLInt)

    with pytest.raises(GraphQLError) as exc_info:
        ast_from_value(None, typ)

    assert "Received Null value for a Non-Null type Int." in str(exc_info.value)
예제 #2
0
def test_ast_from_value_float_precision():

    # Checking precision of float serialization
    # See https://github.com/graphql-python/graphql-core/pull/164

    assert ast_from_value(123456789.01234567, GraphQLFloat) == FloatValueNode(
        value="123456789.01234567"
    )

    assert ast_from_value(1.1, GraphQLFloat) == FloatValueNode(value="1.1")

    assert ast_from_value(123.0, GraphQLFloat) == FloatValueNode(value="123")
예제 #3
0
def test_ast_from_value_with_invalid_type():
    with pytest.raises(TypeError) as exc_info:
        ast_from_value(4, None)

    assert "Unexpected input type: None." in str(exc_info.value)
예제 #4
0
def test_ast_from_value_with_graphqlid():

    assert ast_from_value("12345", GraphQLID) == IntValueNode(value="12345")
예제 #5
0
def test_ast_from_value_with_undefined():
    with pytest.raises(GraphQLError) as exc_info:
        ast_from_value(Undefined, GraphQLInt)

    assert "Received Undefined value for type Int." in str(exc_info.value)
예제 #6
0
def test_ast_from_value_with_none():
    assert ast_from_value(None, GraphQLInt) == NullValueNode()
예제 #7
0
def test_ast_from_value_with_list_type_and_non_iterable_value():
    assert ast_from_value(5, GraphQLList(GraphQLInt)) == IntValueNode(value="5")
예제 #8
0
def test_ast_from_value_with_input_type_and_not_mapping_value():
    obj_type = StarWarsSchema.get_type("ReviewInput")
    assert ast_from_value(8, obj_type) is None