def test_rejects_fragment_names():
    body = '''fragment Foo on Type { field } '''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Foo')

    assert 'Specified query type Foo not found in document' in str(excinfo.value)
def test_rejects_fragment_names():
    body = '''fragment Foo on Type { field } '''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Foo')

    assert 'Specified query type Foo not found in document' in str(excinfo.value)
def test_unknown_type_in_union_list():
    body = '''
union TestUnion = Bar
type Hello { testUnion: TestUnion }
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello')

    assert 'Type Bar not found in document' in str(excinfo.value)
def test_unknown_type_in_union_list():
    body = '''
union TestUnion = Bar
type Hello { testUnion: TestUnion }
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello')

    assert 'Type Bar not found in document' in str(excinfo.value)
def test_rejects_query_names():
    body = '''
type Hello {
  str: String
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Foo')

    assert 'Specified query type Foo not found in document' in str(excinfo.value)
def test_unknown_mutation_type():
    body = '''
type Hello {
  str: String
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello', 'Wat')

    assert 'Specified mutation type Wat not found in document' in str(excinfo.value)
def test_unknown_type_referenced():
    body = '''
type Hello {
  bar: Bar
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello')

    assert 'Type Bar not found in document' in str(excinfo.value)
def test_rejects_query_names():
    body = '''
type Hello {
  str: String
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Foo')

    assert 'Specified query type Foo not found in document' in str(excinfo.value)
def test_unknown_mutation_type():
    body = '''
type Hello {
  str: String
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello', 'Wat')

    assert 'Specified mutation type Wat not found in document' in str(excinfo.value)
def test_unknown_type_referenced():
    body = '''
type Hello {
  bar: Bar
}
'''
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc, 'Hello')

    assert 'Type Bar not found in document' in str(excinfo.value)
def cycle_output(body, query_type, mutation_type=None):
    ast = parse(body)
    schema = build_ast_schema(ast, query_type, mutation_type)
    return '\n' + print_schema(schema)
def cycle_output(body, query_type, mutation_type=None, subscription_type=None):
    ast = parse(body)
    schema = build_ast_schema(ast, query_type, mutation_type, subscription_type)
    return '\n' + print_schema(schema)