/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_chk_map.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-25 14:48:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4477.
  • Revision ID: john@arbash-meinel.com-20090625144813-7uxhjg41f7y0r7uh
add a test case that covers what the new fix actually does.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1894
1894
                                    self).get_chk_bytes()
1895
1895
        return self._chk_bytes
1896
1896
 
1897
 
    def get_map_key(self, a_dict):
1898
 
        c_map = self._get_map(a_dict, maximum_size=10,
 
1897
    def get_map_key(self, a_dict, maximum_size=10):
 
1898
        c_map = self._get_map(a_dict, maximum_size=maximum_size,
1899
1899
                              chk_bytes=self.get_chk_bytes())
1900
1900
        return c_map.key()
1901
1901
 
2154
2154
            ('abb',): 'right'
2155
2155
            })
2156
2156
        basis_map = CHKMap(self.get_chk_bytes(), basis)
2157
 
        basis_map._dump_tree()
 
2157
        self.assertEqualDiff(
 
2158
            "'' InternalNode\n"
 
2159
            "  'a' InternalNode\n"
 
2160
            "    'aa' LeafNode\n"
 
2161
            "      ('aaa',) 'left'\n"
 
2162
            "    'ab' LeafNode\n"
 
2163
            "      ('abb',) 'right'\n"
 
2164
            "  'c' LeafNode\n"
 
2165
            "      ('ccc',) 'common'\n",
 
2166
            basis_map._dump_tree())
2158
2167
        # Get left expected data
2159
2168
        left_map = CHKMap(self.get_chk_bytes(), left)
2160
2169
        self.assertEqualDiff(
2184
2193
             (right, []),
2185
2194
             (l_d_key, [(('ddd',), 'change')]),
2186
2195
            ], [left, right], [basis])
 
2196
 
 
2197
    def test_multiple_maps_similar(self):
 
2198
        # We want to have a depth=2 tree, with multiple entries in each leaf
 
2199
        # node
 
2200
        basis = self.get_map_key({
 
2201
            ('aaa',): 'unchanged',
 
2202
            ('abb',): 'will change left',
 
2203
            ('caa',): 'unchanged',
 
2204
            ('cbb',): 'will change right',
 
2205
            }, maximum_size=60)
 
2206
        left = self.get_map_key({
 
2207
            ('aaa',): 'unchanged',
 
2208
            ('abb',): 'changed left',
 
2209
            ('caa',): 'unchanged',
 
2210
            ('cbb',): 'will change right',
 
2211
            }, maximum_size=60)
 
2212
        right = self.get_map_key({
 
2213
            ('aaa',): 'unchanged',
 
2214
            ('abb',): 'will change left',
 
2215
            ('caa',): 'unchanged',
 
2216
            ('cbb',): 'changed right',
 
2217
            }, maximum_size=60)
 
2218
        basis_map = CHKMap(self.get_chk_bytes(), basis)
 
2219
        self.assertEqualDiff(
 
2220
            "'' InternalNode\n"
 
2221
            "  'a' LeafNode\n"
 
2222
            "      ('aaa',) 'unchanged'\n"
 
2223
            "      ('abb',) 'will change left'\n"
 
2224
            "  'c' LeafNode\n"
 
2225
            "      ('caa',) 'unchanged'\n"
 
2226
            "      ('cbb',) 'will change right'\n",
 
2227
            basis_map._dump_tree())
 
2228
        # Get left expected data
 
2229
        left_map = CHKMap(self.get_chk_bytes(), left)
 
2230
        self.assertEqualDiff(
 
2231
            "'' InternalNode\n"
 
2232
            "  'a' LeafNode\n"
 
2233
            "      ('aaa',) 'unchanged'\n"
 
2234
            "      ('abb',) 'changed left'\n"
 
2235
            "  'c' LeafNode\n"
 
2236
            "      ('caa',) 'unchanged'\n"
 
2237
            "      ('cbb',) 'will change right'\n",
 
2238
            left_map._dump_tree())
 
2239
        # Keys from left side target
 
2240
        l_a_key = left_map._root_node._items['a'].key()
 
2241
        l_c_key = left_map._root_node._items['c'].key()
 
2242
        # Get right expected data
 
2243
        right_map = CHKMap(self.get_chk_bytes(), right)
 
2244
        self.assertEqualDiff(
 
2245
            "'' InternalNode\n"
 
2246
            "  'a' LeafNode\n"
 
2247
            "      ('aaa',) 'unchanged'\n"
 
2248
            "      ('abb',) 'will change left'\n"
 
2249
            "  'c' LeafNode\n"
 
2250
            "      ('caa',) 'unchanged'\n"
 
2251
            "      ('cbb',) 'changed right'\n",
 
2252
            right_map._dump_tree())
 
2253
        r_a_key = right_map._root_node._items['a'].key()
 
2254
        r_c_key = right_map._root_node._items['c'].key()
 
2255
        self.assertIterInteresting(
 
2256
            [(left, []),
 
2257
             (right, []),
 
2258
             (l_a_key, [(('abb',), 'changed left')]),
 
2259
             (r_c_key, [(('cbb',), 'changed right')]),
 
2260
            ], [left, right], [basis])