Rev 3202: More tests checking SortedGraphBuilder. in http://people.ubuntu.com/~robertc/baz2.0/index.hashed
Robert Collins
robertc at robertcollins.net
Sun Jan 27 05:46:33 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/index.hashed
------------------------------------------------------------
revno: 3202
revision-id:robertc at robertcollins.net-20080127054626-tr8weet92u1x5ls2
parent: robertc at robertcollins.net-20080125173648-w4gxwn2gc9ofzi92
committer: Robert Collins <robertc at robertcollins.net>
branch nick: index.hashed
timestamp: Sun 2008-01-27 16:46:26 +1100
message:
More tests checking SortedGraphBuilder.
modified:
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/tests/test_index.py test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2008-01-25 17:36:48 +0000
+++ b/bzrlib/index.py 2008-01-27 05:46:26 +0000
@@ -281,6 +281,9 @@
def _add_custom_headers(self, lines):
"""Output custom headers for this index."""
+ # make a ht class?
+ # for key, (absent, references, value) in self._nodes.iteritems():
+ # string_key = '\x00'.join(key)
lines.append(_OPTION_HASH_BYTES + str(0) + '\n')
lines.append(_OPTION_OFFSET_BYTES + str(0) + '\n')
lines.append(_OPTION_NODE_OFFSET + str(0) + '\n')
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2008-01-25 17:36:48 +0000
+++ b/bzrlib/tests/test_index.py 2008-01-27 05:46:26 +0000
@@ -18,7 +18,7 @@
from bzrlib import errors
from bzrlib.index import *
-from bzrlib.tests import TestCaseWithMemoryTransport
+from bzrlib.tests import TestCaseWithMemoryTransport, TestSkipped
from bzrlib.transport import get_transport
@@ -32,37 +32,29 @@
self.assertEqual(self.build_index_empty_bytes(), contents)
def test_build_index_empty_two_element_keys(self):
- builder = GraphIndexBuilder(key_elements=2)
+ builder = self.make_builder(key_elements=2)
stream = builder.finish()
contents = stream.read()
- self.assertEqual(
- "Bazaar Graph Index 1\nnode_ref_lists=0\nkey_elements=2\nlen=0\n\n",
- contents)
+ self.assertEqual(self.build_index_2_keys_empty_bytes(), contents)
def test_build_index_one_reference_list_empty(self):
- builder = GraphIndexBuilder(reference_lists=1)
+ builder = self.make_builder(reference_lists=1)
stream = builder.finish()
contents = stream.read()
- self.assertEqual(
- "Bazaar Graph Index 1\nnode_ref_lists=1\nkey_elements=1\nlen=0\n\n",
- contents)
+ self.assertEqual(self.build_index_1_list_empty_bytes(), contents)
def test_build_index_two_reference_list_empty(self):
- builder = GraphIndexBuilder(reference_lists=2)
+ builder = self.make_builder(reference_lists=2)
stream = builder.finish()
contents = stream.read()
- self.assertEqual(
- "Bazaar Graph Index 1\nnode_ref_lists=2\nkey_elements=1\nlen=0\n\n",
- contents)
+ self.assertEqual(self.build_index_2_list_empty_bytes(), contents)
def test_build_index_one_node_no_refs(self):
- builder = GraphIndexBuilder()
+ builder = self.make_builder()
builder.add_node(('akey', ), 'data')
stream = builder.finish()
contents = stream.read()
- self.assertEqual(
- "Bazaar Graph Index 1\nnode_ref_lists=0\nkey_elements=1\nlen=1\n"
- "akey\x00\x00\x00data\n\n", contents)
+ self.assertEqual(self.builder_index_1_node_bytes(), contents)
def test_build_index_one_node_no_refs_accepts_empty_reflist(self):
builder = GraphIndexBuilder()
@@ -352,8 +344,9 @@
class TestGraphIndexBuilder(TestCaseWithMemoryTransport, BaseBuilderTests):
- def make_builder(self):
- return GraphIndexBuilder()
+ def make_builder(self, key_elements=1, reference_lists=0):
+ return GraphIndexBuilder(key_elements=key_elements,
+ reference_lists=reference_lists)
def build_index_empty_bytes(self):
return (
@@ -363,11 +356,45 @@
"len=0\n"
"\n")
+ def build_index_2_keys_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 1\n"
+ "node_ref_lists=0\n"
+ "key_elements=2\n"
+ "len=0\n"
+ "\n")
+
+ def build_index_1_list_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 1\n"
+ "node_ref_lists=1\n"
+ "key_elements=1\n"
+ "len=0\n"
+ "\n")
+
+ def build_index_2_list_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 1\n"
+ "node_ref_lists=2\n"
+ "key_elements=1\n"
+ "len=0\n"
+ "\n")
+
+ def builder_index_1_node_bytes(self):
+ return (
+ "Bazaar Graph Index 1\n"
+ "node_ref_lists=0\n"
+ "key_elements=1\n"
+ "len=1\n"
+ "akey\x00\x00\x00data\n"
+ "\n")
+
class TestSortedGraphIndexBuilder(TestCaseWithMemoryTransport, BaseBuilderTests):
- def make_builder(self):
- return SortedGraphIndexBuilder()
+ def make_builder(self, key_elements=1, reference_lists=0):
+ return SortedGraphIndexBuilder(key_elements=key_elements,
+ reference_lists=reference_lists)
def build_index_empty_bytes(self):
return (
@@ -381,6 +408,56 @@
"\n"
"\n")
+ def build_index_2_keys_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 2\n"
+ "node_ref_lists=0\n"
+ "key_elements=2\n"
+ "len=0\n"
+ "hash_bytes=0\n"
+ "offset_bytes=0\n"
+ "node_offset=0\n"
+ "\n"
+ "\n")
+
+ def build_index_1_list_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 2\n"
+ "node_ref_lists=1\n"
+ "key_elements=1\n"
+ "len=0\n"
+ "hash_bytes=0\n"
+ "offset_bytes=0\n"
+ "node_offset=0\n"
+ "\n"
+ "\n")
+
+ def build_index_2_list_empty_bytes(self):
+ return (
+ "Bazaar Graph Index 2\n"
+ "node_ref_lists=2\n"
+ "key_elements=1\n"
+ "len=0\n"
+ "hash_bytes=0\n"
+ "offset_bytes=0\n"
+ "node_offset=0\n"
+ "\n"
+ "\n")
+
+ def builder_index_1_node_bytes(self):
+ raise TestSkipped('not ready yet')
+ return (
+ "Bazaar Graph Index 1\n"
+ "node_ref_lists=0\n"
+ "key_elements=1\n"
+ "len=1\n"
+ "hash_bytes=1\n"
+ "offset_bytes=1\n"
+ "node_offset=0\n"
+ "\x67\n"
+ "akey\x00\x00\x00data\n"
+ "\n")
+
class TestGraphIndex(TestCaseWithMemoryTransport):
More information about the bazaar-commits
mailing list