~toddy/bzr/bzr.i18n

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Tobias Toedter
  • Date: 2007-12-30 18:52:13 UTC
  • mfrom: (2438.1.708 +trunk)
  • Revision ID: t.toedter@gmx.net-20071230185213-7xiqpbtshmnsf073
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
 
153
153
 
154
154
class TestCoalesceOffsets(TestCase):
155
 
    
156
 
    def check(self, expected, offsets, limit=0, fudge=0):
 
155
 
 
156
    def check(self, expected, offsets, limit=0, max_size=0, fudge=0):
157
157
        coalesce = Transport._coalesce_offsets
158
158
        exp = [_CoalescedOffset(*x) for x in expected]
159
 
        out = list(coalesce(offsets, limit=limit, fudge_factor=fudge))
 
159
        out = list(coalesce(offsets, limit=limit, fudge_factor=fudge,
 
160
                            max_size=max_size))
160
161
        self.assertEqual(exp, out)
161
162
 
162
163
    def test_coalesce_empty(self):
169
170
        self.check([(0, 10, [(0, 10)]),
170
171
                    (20, 10, [(0, 10)]),
171
172
                   ], [(0, 10), (20, 10)])
172
 
            
 
173
 
173
174
    def test_coalesce_unsorted(self):
174
175
        self.check([(20, 10, [(0, 10)]),
175
176
                    (0, 10, [(0, 10)]),
179
180
        self.check([(0, 20, [(0, 10), (10, 10)])],
180
181
                   [(0, 10), (10, 10)])
181
182
 
 
183
    # XXX: scary, http.readv() can't handle that --vila20071209
182
184
    def test_coalesce_overlapped(self):
183
185
        self.check([(0, 15, [(0, 10), (5, 10)])],
184
186
                   [(0, 10), (5, 10)])
208
210
                   ], [(10, 10), (30, 10), (100, 10)],
209
211
                   fudge=10
210
212
                  )
 
213
    def test_coalesce_max_size(self):
 
214
        self.check([(10, 20, [(0, 10), (10, 10)]),
 
215
                    (30, 50, [(0, 50)]),
 
216
                    # If one range is above max_size, it gets its own coalesced
 
217
                    # offset
 
218
                    (100, 80, [(0, 80),]),],
 
219
                   [(10, 10), (20, 10), (30, 50), (100, 80)],
 
220
                   max_size=50
 
221
                  )
 
222
 
 
223
    def test_coalesce_no_max_size(self):
 
224
        self.check([(10, 170, [(0, 10), (10, 10), (20, 50), (70, 100)]),],
 
225
                   [(10, 10), (20, 10), (30, 50), (80, 100)],
 
226
                  )
211
227
 
212
228
 
213
229
class TestMemoryTransport(TestCase):