def test_reference_str_serialization(): tree_conf = TreeConf(4096, 4, 40, 40, StrSerializer()) r1 = Reference(tree_conf, 'foo', 1, 2) data = r1.dump() r2 = Reference(tree_conf, data=data) assert r1 == r2 assert r1.before == r2.before assert r1.after == r2.after
def test_record_str_serialization(): tree_conf = TreeConf(4096, 4, 40, 40, StrSerializer()) r1 = Record(tree_conf, '0', b'0') data = r1.dump() r2 = Record(tree_conf, data=data) assert r1 == r2 assert r1.value == r2.value assert r1.overflow_page == r2.overflow_page
def test_get_node_from_page_data(): data = int(2).to_bytes(1, ENDIAN) + bytes(4096 - 1) _tree_conf = TreeConf(4096, 7, 16, 16, IntSerializer()) assert isinstance(Node.from_page_data(_tree_conf, data, 4), RootNode)
# -*- coding: utf-8 -*- import pytest from gbplustree.entry import Record, Reference from gbplustree.const import TreeConf from gbplustree.serializer import (IntSerializer, StrSerializer) tree_conf = TreeConf(4096, 4, 16, 16, IntSerializer()) def test_record_int_serialization(): r1 = Record(tree_conf, 42, b'foo') data = r1.dump() r2 = Record(tree_conf, data=data) assert r1 == r2 assert r1.value == r2.value assert r1.overflow_page == r2.overflow_page def test_record_str_serialization(): tree_conf = TreeConf(4096, 4, 40, 40, StrSerializer()) r1 = Record(tree_conf, '0', b'0') data = r1.dump() r2 = Record(tree_conf, data=data) assert r1 == r2 assert r1.value == r2.value
def test_node_limit_children(klass, order, min_children, max_children): node = klass(TreeConf(4096, order, 16, 16, IntSerializer())) assert node.min_children == min_children assert node.max_children == max_children