diff test/test_liveserver.py @ 7816:1b5daee24dc7

test: fix test for invalid etag in if-range. The broken etag was missing the initial ", so the wrong code path was duplicated. Also add test that correct size of file was returned and fix comment(s).
author John Rouillard <rouilj@ieee.org>
date Sun, 17 Mar 2024 00:55:29 -0400
parents ec59729b3b7e
children 0fe2b9f6e19f
line wrap: on
line diff
--- a/test/test_liveserver.py	Sun Mar 17 00:51:12 2024 -0400
+++ b/test/test_liveserver.py	Sun Mar 17 00:55:29 2024 -0400
@@ -240,7 +240,7 @@
         self.assertEqual(f.headers['content-range'],
                          "bytes 10-20/%s"%expected_length)
 
-        # get all bytest starting from 11
+        # get all bytes starting from 11
         hdrs = {"Range": "bytes=11-"}
         f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
         self.assertEqual(f.status_code, 206)
@@ -269,10 +269,11 @@
 
         # range is too large, but etag is bad also, return whole file 200 code
         hdrs['Range'] = "0-99999" # too large
-        hdrs['If-Range'] = etag[2:]  # bad tag
+        hdrs['If-Range'] = '"' + etag[2:]  # start bad tag with "
         f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
         self.assertEqual(f.status_code, 200)
-        # not checking content length since it could be compressed
+        # note f.content has content-encoding (compression) undone.
+        self.assertEqual(len(f.content), int(expected_length))
         self.assertNotIn('content-range', f.headers, 'content-range should not be present')
 
         # range is too large, but etag is specified so return whole file

Roundup Issue Tracker: http://roundup-tracker.org/