~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tests/test_groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-04 21:06:22 UTC
  • mto: (0.17.34 trunk)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090304210622-ur7wz2dz0w4lhzn3
(tests broken) implement the basic ability to have a separate header
This puts the labels/sha1/etc together, and then has the actual content deltas
combined later on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
        # Knit fetching will try to reconstruct texts locally which results in
158
158
        # reading something that is in the compressor stream already.
159
159
        compressor = groupcompress.GroupCompressor(True)
160
 
        sha_1,  _ = compressor.compress(('label',), 'strange\ncommon\n', None)
161
 
        sha_2, _ = compressor.compress(('newlabel',),
162
 
            'common\ndifferent\nmoredifferent\n', None)
 
160
        sha1_1, _ = compressor.compress(('label',),
 
161
            'strange\ncommon long line\nthat needs a 16 byte match\n', None)
 
162
        expected_lines = list(compressor.lines)
 
163
        sha1_2, end_point = compressor.compress(('newlabel',),
 
164
            'common long line\nthat needs a 16 byte match\ndifferent\n', None)
163
165
        # get the first out
164
 
        self.assertEqual((['strange\ncommon\n'], sha_1),
 
166
        self.assertEqual(('strange\ncommon\n', sha1_1),
165
167
            compressor.extract(('label',)))
166
168
        # and the second
167
 
        self.assertEqual((['common\ndifferent\nmoredifferent\n'],
168
 
            sha_2), compressor.extract(('newlabel',)))
 
169
        self.assertEqual(('common long line\nthat needs a 16 byte match\n'
 
170
                          'different\n', sha1_2),
 
171
                         compressor.extract(('newlabel',)))
169
172
 
170
173
 
171
174
class TestBase128Int(tests.TestCase):
214
217
        self.assertEqual({}, block._entries)
215
218
 
216
219
    def test_from_bytes(self):
217
 
        block = groupcompress.GroupCompressBlock.from_bytes(
 
220
        z_header_bytes = (
218
221
            'gcb1z\n' # group compress block v1 plain
219
222
            '76\n' # Length of zlib bytes
220
223
            '183\n' # Length of all meta-info
231
234
            'start:0\n'
232
235
            'length:100\n'
233
236
            '\n'))
 
237
        block = groupcompress.GroupCompressBlock.from_bytes(
 
238
            z_header_bytes)
 
239
        self.assertIs(None, block._content)
 
240
        self.assertIsInstance(block, groupcompress.GroupCompressBlock)
234
241
        self.assertEqual([('bing',), ('foo', 'bar')], sorted(block._entries))
235
242
        bing = block._entries[('bing',)]
236
243
        self.assertEqual(('bing',), bing.key)