예제 #1
0
def test_children():
    parent = Node(Node(TEST_DATA), Node(TEST_DATA))
    assert len(parent.children()) == 2

    parent = Node(Node(TEST_DATA), Node(TEST_DATA))
    assert len(parent.children()) == 2

    parent = Node(Node(Node(TEST_DATA)))
    assert len(parent.children()) == 2

    parent = Node(dict(docs=Node(Node(TEST_DATA))))
    assert len(parent.children()) == 2

    parent = Node([dict(docs=Node(Node(TEST_DATA))), Node(TEST_DATA)])
    assert len(parent.children()) == 3

    parent = Node(dict(docs=[Node(Node(TEST_DATA)), Node(TEST_DATA)]))
    assert len(parent.children()) == 3

    parent = Node("STRING")
    assert (len(parent.children())) == 0

    parent = Node("STRING", Node("STRING"))
    assert (len(parent.children())) == 1
예제 #2
0
def test_child():
    child = Node(TEST_DATA)
    parent = Node(child)
    children = parent.children()
    assert child in children
    assert len(children) == 1