[Zope-Checkins] CVS: Zope/lib/python/ZPublisher/tests - testHTTPRangeSupport.py:1.5.4.2

Martijn Pieters mj@zope.com
Wed, 21 Aug 2002 17:44:14 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher/tests
In directory cvs.zope.org:/tmp/cvs-serv18973/ZPublisher/tests

Modified Files:
      Tag: zope-2_3-branch
	testHTTPRangeSupport.py 
Log Message:
Merge of byte range fix for the benefit of Zope.org.


=== Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py 1.5.4.1 => 1.5.4.2 ===
--- Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py:1.5.4.1	Sat Jul 13 17:14:25 2002
+++ Zope/lib/python/ZPublisher/tests/testHTTPRangeSupport.py	Wed Aug 21 17:44:13 2002
@@ -86,10 +86,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
 
@@ -154,10 +154,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`))
 
@@ -167,32 +167,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)])
@@ -201,7 +204,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():