430
430
self.assertEqual('user_encoding', osutils.get_terminal_encoding())
433
class TestOffsets(TestCase):
434
"""Test test_offsets_to_ranges method that is used to convert
435
readv into combined ranges."""
437
def test_offsets_to_http_ranges(self):
438
to_range = osutils.offsets_to_http_ranges
439
ranges, tail = to_range([(10, 1), (20, 2), (22, 5)])
440
self.assertEquals(tuple(ranges[0]), (10, 10))
441
self.assertEquals(tuple(ranges[1]), (20, 26))
442
self.assertEquals(tail, 0)
444
ranges, tail = to_range([(10, 1), (11, 2), (22, 5), (-4, 4)])
445
self.assertEquals(tuple(ranges[0]), (10, 12))
446
self.assertEquals(tuple(ranges[1]), (22, 26))
447
self.assertEquals(tail, 4)
449
ranges, tail = to_range([(-4, 4), (-8, 8)])
450
self.assertEquals(tuple(ranges), ())
451
self.assertEquals(tail, 8)
453
ranges, tail = to_range([(10, 1), (20, 2)], fudge_factor=9)
454
self.assertEquals(tuple(ranges[0]), (10, 21))
455
self.assertEquals(len(ranges), 1)
456
self.assertEquals(tail, 0)
458
ranges, tail = to_range([(10, 1), (20, 2)], fudge_factor=8)
459
self.assertEquals(tuple(ranges[0]), (10, 10))
460
self.assertEquals(tuple(ranges[1]), (20, 21))
461
self.assertEquals(tail, 0)