[Zope-Checkins] CVS: Zope/lib/python/ZPublisher/tests - testHTTPRangeSupport.py:1.4.10.1
Martijn Pieters
mj@zope.com
Wed, 21 Aug 2002 16:51:19 -0400
Update of /cvs-repository/Zope/lib/python/ZPublisher/tests
In directory cvs.zope.org:/tmp/cvs-serv9798/ZPublisher/tests
Modified Files:
Tag: Zope-2_5-branch
testHTTPRangeSupport.py
Log Message:
Fix for Zope Collector issue #530 (http://collector.zope.org/Zope/530);
Adobe Acrobat for windows hangs on optimized byte ranges.
- Improve file byte range serving to allow arbitrary order byte ranges.
- Drop optimizations of byte ranges altogether; rename the method to
expandRanges. This means we'll have to swallow loosing the small bandwidth
wins we got from merging overlapping ranges (which was allowed under the
RFC).
- Update the tests to follow the changes.
=== Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py 1.4 => 1.4.10.1 ===
--- Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py:1.4 Tue Dec 4 17:51:10 2001
+++ Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py Wed Aug 21 16:51:18 2002
@@ -14,10 +14,10 @@
import sys
sys.path.insert(0, '.')
try:
- from ZPublisher.HTTPRangeSupport import parseRange, optimizeRanges
+ from ZPublisher.HTTPRangeSupport import parseRange, expandRanges
except ImportError:
sys.path[0]='../..'
- from ZPublisher.HTTPRangeSupport import parseRange, optimizeRanges
+ from ZPublisher.HTTPRangeSupport import parseRange, expandRanges
import unittest
@@ -82,10 +82,10 @@
self.expectSets('bytes=-0', [(sys.maxint, None)])
-class TestOptimizeRanges(unittest.TestCase):
+class TestExpandRanges(unittest.TestCase):
def expectSets(self, sets, size, expect):
- result = optimizeRanges(sets, size)
+ result = expandRanges(sets, size)
self.failUnless(result == expect,
'Expected %s, got %s' % (`expect`, `result`))
@@ -95,32 +95,35 @@
def testMakeAbsolute(self):
self.expectSets([(1, 2), (-5, None)], 50, [(1, 2), (45, 50)])
+ # The following set of tests were developed for when ranges where optimized
+ # and may make less sense with the current code. They are retained as rich
+ # tests for future changes, however.
def testNoOverlapInOrder(self):
self.expectSets([(1, 5), (1000, 2000), (3000, None)], 5000,
[(1, 5), (1000, 2000), (3000, 5000)])
def testNoOverlapOutOfOrder(self):
self.expectSets([(1000, 2000), (3000, None), (1, 5)], 5000,
- [(1, 5), (1000, 2000), (3000, 5000)])
+ [(1000, 2000), (3000, 5000), (1, 5)])
def testOverlapInOrder(self):
self.expectSets([(1, 10), (8, 20), (25, None)], 5000,
- [(1, 20), (25, 5000)])
+ [(1, 10), (8, 20), (25, 5000)])
def testOverlapOutOfOrder(self):
self.expectSets([(25, 50), (8, None), (1, 10)], 5000,
- [(1, 5000)])
+ [(25, 50), (8, 5000), (1, 10)])
def testAdjacentInOrder(self):
self.expectSets([(1, 10), (10, 20), (25, 50)], 5000,
[(1, 10), (10, 20), (25, 50)])
def testAdjacentOutOfOrder(self):
- self.expectSets([(-5, None), (40, 45)], 50, [(40, 45), (45, 50)])
+ self.expectSets([(-5, None), (40, 45)], 50, [(45, 50), (40, 45)])
- def testOverLapAndOverflow(self):
+ def testOverlapAndOverflow(self):
# Note that one endpoint lies beyond the end.
- self.expectSets([(-5, None), (40, 100)], 50, [(40, 50)])
+ self.expectSets([(-5, None), (40, 100)], 50, [(45, 50), (40, 50)])
def testRemoveUnsatisfiable(self):
self.expectSets([(sys.maxint, None), (10, 20)], 50, [(10, 20)])
@@ -129,7 +132,7 @@
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRangeHeaderParse, 'test'))
- suite.addTest(unittest.makeSuite(TestOptimizeRanges, 'test'))
+ suite.addTest(unittest.makeSuite(TestExpandRanges, 'test'))
return suite
def main():