~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tests/test_groupcompress.py

Add extraction of just-compressed texts to support converting from knits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        compressor.compress(('label3',),
137
137
            ['new\n', 'common\n', 'different\n', 'moredifferent\n'], None)
138
138
        self.assertAlmostEqual(0.3, compressor.ratio(), 1)
 
139
 
 
140
    def test_extract_from_compressor(self):
 
141
        # Knit fetching will try to reconstruct texts locally which results in
 
142
        # reading something that is in the compressor stream already.
 
143
        compressor = groupcompress.GroupCompressor(True)
 
144
        sha_1,  _ = compressor.compress(('label',),
 
145
            ['strange\n', 'common\n'], None)
 
146
        sha_2, _ = compressor.compress(('newlabel',),
 
147
            ['common\n', 'different\n', 'moredifferent\n'], None)
 
148
        # get the first out
 
149
        self.assertEqual((['strange\n', 'common\n'], sha_1),
 
150
            compressor.extract(('label',)))
 
151
        # and the second
 
152
        self.assertEqual((['common\n', 'different\n', 'moredifferent\n'],
 
153
            sha_2), compressor.extract(('newlabel',)))