Пример #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):
Пример #2
0
def test_single_nullable_field():
    grapple_string = """type Test @generatePent {name: String}"""
    grapple_document = parse_grapple(grapple_string)
    grapple_type = grapple_document.object_types()[0]
    assert grapple_type.name() == 'Test'
    fields = grapple_type.fields()
    assert len(fields) == 1
    name_field = fields[0]
    assert name_field.name() == 'name'
    assert name_field.type_ref().graphql_type() == 'String'
    assert name_field.type_ref().python_type() == 'str'
    output = print_grapple_pents(grapple_document)
    assert output == \
"""class TestGenerated(Pent):
Пример #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 == ""
Пример #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):