~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-25 21:13:22 UTC
  • mto: This revision was merged to the branch mainline in revision 4051.
  • Revision ID: john@arbash-meinel.com-20090225211322-qc94czk3s1g7nliq
Some direct tests for _group_keys_for_io

Show diffs side-by-side

added added

removed removed

Lines of Context:
1889
1889
 
1890
1890
class TestKnitVersionedFiles(KnitTests):
1891
1891
 
 
1892
    def assertGroupKeysForIo(self, exp_groups, keys, non_local_keys,
 
1893
                             positions, _min_buffer_size=None):
 
1894
        kvf = self.make_test_knit()
 
1895
        if _min_buffer_size is None:
 
1896
            _min_buffer_size = knit._STREAM_MIN_BUFFER_SIZE
 
1897
        self.assertEqual(exp_groups, kvf._group_keys_for_io(keys,
 
1898
                                        non_local_keys, positions,
 
1899
                                        _min_buffer_size=_min_buffer_size))
 
1900
 
1892
1901
    def assertSplitByPrefix(self, expected_map, expected_prefix_order,
1893
1902
                            keys):
1894
1903
        split, prefix_order = KnitVersionedFiles._split_by_prefix(keys)
1895
1904
        self.assertEqual(expected_map, split)
1896
1905
        self.assertEqual(expected_prefix_order, prefix_order)
1897
1906
 
 
1907
    def test__group_keys_for_io(self):
 
1908
        ft_detail = ('fulltext', False)
 
1909
        ld_detail = ('line-delta', False)
 
1910
        f_a = ('f', 'a')
 
1911
        f_b = ('f', 'b')
 
1912
        f_c = ('f', 'c')
 
1913
        g_a = ('g', 'a')
 
1914
        g_b = ('g', 'b')
 
1915
        g_c = ('g', 'c')
 
1916
        positions = {
 
1917
            f_a: (ft_detail, (f_a, 0, 100), None),
 
1918
            f_b: (ld_detail, (f_b, 100, 21), f_a),
 
1919
            f_c: (ld_detail, (f_c, 180, 15), f_b),
 
1920
            g_a: (ft_detail, (g_a, 121, 35), None),
 
1921
            g_b: (ld_detail, (g_b, 156, 12), g_a),
 
1922
            g_c: (ld_detail, (g_c, 195, 13), g_a),
 
1923
            }
 
1924
        self.assertGroupKeysForIo([([f_a], set())],
 
1925
                                  [f_a], [], positions)
 
1926
        self.assertGroupKeysForIo([([f_a], set([f_a]))],
 
1927
                                  [f_a], [f_a], positions)
 
1928
        self.assertGroupKeysForIo([([f_a, f_b], set([]))],
 
1929
                                  [f_a, f_b], [], positions)
 
1930
        self.assertGroupKeysForIo([([f_a, f_b], set([f_b]))],
 
1931
                                  [f_a, f_b], [f_b], positions)
 
1932
        self.assertGroupKeysForIo([([f_a, f_b, g_a, g_b], set())],
 
1933
                                  [f_a, g_a, f_b, g_b], [], positions)
 
1934
        self.assertGroupKeysForIo([([f_a, f_b, g_a, g_b], set())],
 
1935
                                  [f_a, g_a, f_b, g_b], [], positions,
 
1936
                                  _min_buffer_size=150)
 
1937
        self.assertGroupKeysForIo([([f_a, f_b], set()), ([g_a, g_b], set())],
 
1938
                                  [f_a, g_a, f_b, g_b], [], positions,
 
1939
                                  _min_buffer_size=100)
 
1940
        self.assertGroupKeysForIo([([f_c], set()), ([g_b], set())],
 
1941
                                  [f_c, g_b], [], positions,
 
1942
                                  _min_buffer_size=125)
 
1943
        self.assertGroupKeysForIo([([g_b, f_c], set())],
 
1944
                                  [g_b, f_c], [], positions,
 
1945
                                  _min_buffer_size=125)
 
1946
 
1898
1947
    def test__split_by_prefix(self):
1899
1948
        self.assertSplitByPrefix({'f': [('f', 'a'), ('f', 'b')],
1900
1949
                                  'g': [('g', 'b'), ('g', 'a')],