~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-13 13:11:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060713131106-4f059a8003d852bd
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
430
430
        self.assertEqual('user_encoding', osutils.get_terminal_encoding())
431
431
 
432
432
 
433
 
class TestOffsets(TestCase):
434
 
    """Test test_offsets_to_ranges method that is used to convert
435
 
    readv into combined ranges."""
436
 
 
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)
443
 
 
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)
448
 
 
449
 
        ranges, tail = to_range([(-4, 4), (-8, 8)])
450
 
        self.assertEquals(tuple(ranges), ())
451
 
        self.assertEquals(tail, 8)
452
 
 
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)
457
 
 
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)
462
 
 
463
 
 
464