예제 #1
0
def get_test_document():
    document = Document(DocumentMetadata())
    node = document.create_node(type='foo')
    node.content = "cheese"
    document.content_node = node

    document.content_node.add_child(
        document.create_node(type='bar', content='fishstick'))
    return document
예제 #2
0
def create_document():
    document = Document(DocumentMetadata())
    node = document.create_node(type='foo')
    node.content = "cheese"
    document.content_node = node

    foo2 = document.create_node(type='bar')
    foo2.content = "fishstick"
    document.content_node.add_child(foo2)
    return document
예제 #3
0
def create_document():
    document = Document(DocumentMetadata())
    document.source.original_filename = "test.doc"
    node = document.create_node(node_type='foo')
    node.content = "cheese"
    document.content_node = node

    foo2 = document.create_node(node_type='bar')
    foo2.content = "fishstick"
    document.content_node.add_child(foo2)
    return document
예제 #4
0
def get_test_document_with_three_children():
    document = Document(DocumentMetadata())
    node = document.create_node(type='foo')
    node.content = "cheese"
    document.content_node = node

    document.content_node.add_child(
        document.create_node(type='bar', content='fishstick'))
    document.content_node.add_child(
        document.create_node(type='bar', content='cheeseburger'))
    document.content_node.add_child(
        document.create_node(type='bar', content='beans'))

    return document
예제 #5
0
def test_virtual_navigation_with_no_0_index():
    document = Document(DocumentMetadata())
    document.add_mixin('core')
    node = document.create_node(type='loopy')
    node.content = "banana"
    document.content_node = node

    document.content_node.add_child(document.create_node(type='loopy',
                                                         content='banana2'),
                                    index=2)

    assert document.content_node.get_node_at_index(0).content is None
    assert document.content_node.get_node_at_index(
        0).next_node().content is None
    assert document.content_node.get_node_at_index(
        0).next_node().next_node().content is 'banana2'
예제 #6
0
def test_virtual_navigation_with_no_0_index():
    document = Document(DocumentMetadata())
    node = document.create_node(node_type='loopy')
    node.content = "banana"
    document.content_node = node

    document.content_node.add_child(document.create_node(node_type='loopy',
                                                         content='banana2'),
                                    index=2)

    assert document.content_node.get_node_at_index(0).content is None
    assert document.content_node.get_node_at_index(
        0).next_node().content is None
    assert document.content_node.get_node_at_index(
        0).next_node().next_node().content == 'banana2'

    test_kddb = document.to_kddb()
    new_kddb = Document.from_kddb(test_kddb)

    assert new_kddb.content_node.get_node_at_index(0).content is None
    assert new_kddb.content_node.get_node_at_index(
        0).next_node().content is None
    assert new_kddb.content_node.get_node_at_index(
        0).next_node().next_node().content == 'banana2'