diff options
author | cce <devnull@localhost> | 2005-12-29 18:16:59 +0000 |
---|---|---|
committer | cce <devnull@localhost> | 2005-12-29 18:16:59 +0000 |
commit | 5c466f7cef6a16ab03067dbbc61d940f26a186a5 (patch) | |
tree | e73906c72aad99fd11fa9f2361eb0f5949e7c407 /tests/test_fileapp.py | |
parent | c4a7ac89559ee520845b7a1652c85e363fb0e66a (diff) | |
download | paste-5c466f7cef6a16ab03067dbbc61d940f26a186a5.tar.gz |
- added Range.parse to httpheaders
- renamed Expires.time to Expires.parse for consistency
- updated FileApp/DataApp to return 206 on Partial Content
- all HttpHeader(environ) return strings (empty string when not found)
so that checks like 'if header-part in HttpHeader(collection)'
works without having to check for None
- updated FileApp to use Range header (instead of having its own copy)
Diffstat (limited to 'tests/test_fileapp.py')
-rw-r--r-- | tests/test_fileapp.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/test_fileapp.py b/tests/test_fileapp.py index 90b0e5c..c02da52 100644 --- a/tests/test_fileapp.py +++ b/tests/test_fileapp.py @@ -120,6 +120,7 @@ def test_file(): os.unlink(tempfile) def _excercize_range(build,content): + # full content request, but using ranges' res = build("bytes=0-%d" % (len(content)-1)) assert res.header('accept-ranges') == 'bytes' assert res.body == content @@ -130,21 +131,22 @@ def _excercize_range(build,content): res = build("bytes=0-") assert res.body == content assert res.header('content-length') == str(len(content)) - res = build("bytes=0-9") + # partial content requests + res = build("bytes=0-9", status=206) assert res.body == content[:10] assert res.header('content-length') == '10' - res = build("bytes=%d-" % (len(content)-1)) + res = build("bytes=%d-" % (len(content)-1), status=206) assert res.body == 'Z' assert res.header('content-length') == '1' - res = build("bytes=%d-%d" % (3,17)) + res = build("bytes=%d-%d" % (3,17), status=206) assert res.body == content[3:18] assert res.header('content-length') == '15' def test_range(): content = string.letters * 5 - def build(range): + def build(range, status=200): app = DataApp(content) - return TestApp(app).get("/",headers={'Range': range}) + return TestApp(app).get("/",headers={'Range': range}, status=status) _excercize_range(build,content) def test_file_range(): @@ -157,9 +159,10 @@ def test_file_range(): file.write(content) file.close() try: - def build(range): + def build(range, status=200): app = fileapp.FileApp(tempfile) - return TestApp(app).get("/",headers={'Range': range}) + return TestApp(app).get("/",headers={'Range': range}, + status=status) _excercize_range(build,content) for size in (13,len(string.letters),len(string.letters)-1): fileapp.BLOCK_SIZE = size |