def test_file_memory_node(): mem = FileMemory(filename, tree_conf) with pytest.raises(ReachedEndOfFile): mem.get_node(3) mem.set_node(node) assert node == mem.get_node(3) mem.close()
def test_file_memory_write_transaction(): mem = FileMemory(filename, tree_conf) mem._lock = mock.Mock() assert mem._wal._not_committed_pages == {} assert mem._wal._committed_pages == {} with mem.write_transaction: mem.set_node(node) assert mem._wal._not_committed_pages == {3: 9} assert mem._wal._committed_pages == {} assert mem._lock.writer_lock.acquire.call_count == 1 assert mem._wal._not_committed_pages == {} assert mem._wal._committed_pages == {3: 9} assert mem._lock.writer_lock.release.call_count == 1 assert mem._lock.reader_lock.acquire.call_count == 0 with mem.read_transaction: assert mem._lock.reader_lock.acquire.call_count == 1 assert node == mem.get_node(3) assert mem._lock.reader_lock.release.call_count == 1 mem.close()
def test_file_memory_repr(): mem = FileMemory(filename, tree_conf) assert repr(mem) == '<FileMemory: {}>'.format(filename) mem.close()