Example #1
0
def test_required_field():
    grapple_string = """type TestRequired @generatePent {id: ID!, name: String!}"""
    grapple_document = parse_grapple(grapple_string)
    output = print_grapple_pents(grapple_document)
    # print('OUTPUT')
    # print(output.replace(' ', '-'))
    # print('END OUTPUT')
    assert output == \
"""class TestRequiredGenerated(Pent):
Example #2
0
def test_enum():
    graphql = """
type Hospital {
    status: HospitalStatus
    reqStatus: HospitalStatus!
}

enum HospitalStatus {
    AS_SUBMITTED
}
"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLHospital(GrappleType):
Example #3
0
def test_no_grapple_types():
    grapple_string = """type TestObjectField {bar: FooBar}"""
    grapple_document = parse_grapple(grapple_string)
    output = print_grapple_pents(grapple_document)
    assert output == ""
Example #4
0
def test_object_field():
    grapple_string = """type TestObjectField @generatePent {bar: FooBar}"""
    grapple_document = parse_grapple(grapple_string)
    output = print_grapple_pents(grapple_document)
    assert output == \
"""class TestObjectFieldGenerated(Pent):
Example #5
0
def test_req_list_of_reqs():
    graphql = """type Test { names: [String!]! }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):
Example #6
0
def test_basic_type():
    graphql = """type Test { name: String }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):
Example #7
0
def test_non_pythonic_name():
    graphql = """type Test { longName: String }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):
Example #8
0
def test_args():
    graphql = """type Test { relatives(skip: Int, take: Int) : [Test] }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):
Example #9
0
def test_ref_to_self():
    graphql = """type Test { other: Test }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):
Example #10
0
def test_double_list():
    graphql = """type Test { matrix: [[String]] }"""
    result = print_graphql_defs(parse_grapple(graphql))
    assert result == """class GraphQLTest(GrappleType):