Beispiel #1
0
def testSimpleReadWrite(nodesLeaves, tempdir):
    nodes, leaves = nodesLeaves
    fhs = FileHashStore(tempdir)

    for leaf in leaves:
        fhs.writeLeaf(leaf)
    for i, leaf in enumerate(leaves):
        assert leaf == fhs.readLeaf(i + 1)

    for node in nodes:
        fhs.writeNode(node)
    for i, node in enumerate(nodes):
        assert node[2] == fhs.readNode(i + 1)

    lvs = fhs.readLeafs(1, len(leaves))
    for i, l in enumerate(lvs):
        assert leaves[i] == l

    nds = fhs.readNodes(1, len(nodes))
    for i, n in enumerate(nds):
        assert nodes[i][2] == n

    # Check that hash store can be closed and re-opened and the contents remain same
    leaf_count = fhs.leafCount
    node_count = fhs.nodeCount
    fhs.close()
    reopened_hash_store = FileHashStore(tempdir)
    assert reopened_hash_store.leafCount == leaf_count
    assert reopened_hash_store.nodeCount == node_count
def testSimpleReadWrite(nodesLeaves, tempdir):
    nodes, leaves = nodesLeaves
    fhs = FileHashStore(tempdir)

    for leaf in leaves:
        fhs.writeLeaf(leaf)
    for i, leaf in enumerate(leaves):
        assert leaf == fhs.readLeaf(i + 1)

    for node in nodes:
        fhs.writeNode(node)
    for i, node in enumerate(nodes):
        assert node[2] == fhs.readNode(i + 1)

    lvs = fhs.readLeafs(1, len(leaves))
    for i, l in enumerate(lvs):
        assert leaves[i] == l

    nds = fhs.readNodes(1, len(nodes))
    for i, n in enumerate(nds):
        assert nodes[i][2] == n