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',)))
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',)))
171
174
class TestBase128Int(tests.TestCase):
214
217
self.assertEqual({}, block._entries)
216
219
def test_from_bytes(self):
217
block = groupcompress.GroupCompressBlock.from_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
237
block = groupcompress.GroupCompressBlock.from_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)