summaryrefslogtreecommitdiff
path: root/tests/test_httpheaders.py
diff options
context:
space:
mode:
authorcce <devnull@localhost>2005-12-29 18:16:59 +0000
committercce <devnull@localhost>2005-12-29 18:16:59 +0000
commit5c466f7cef6a16ab03067dbbc61d940f26a186a5 (patch)
treee73906c72aad99fd11fa9f2361eb0f5949e7c407 /tests/test_httpheaders.py
parentc4a7ac89559ee520845b7a1652c85e363fb0e66a (diff)
downloadpaste-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_httpheaders.py')
-rw-r--r--tests/test_httpheaders.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/test_httpheaders.py b/tests/test_httpheaders.py
index c8d25ba..495553d 100644
--- a/tests/test_httpheaders.py
+++ b/tests/test_httpheaders.py
@@ -26,14 +26,16 @@ def test_environ():
}
def test_environ_cgi():
- environ = {'CONTENT_TYPE': 'server/supplied', 'wsgi.version': '1.0',
- 'HTTP_CONTENT_TYPE': 'text/plain', 'CONTENT_LENGTH': '200'}
+ environ = {'CONTENT_TYPE': 'text/plain', 'wsgi.version': '1.0',
+ 'HTTP_CONTENT_TYPE': 'ignored/invalid',
+ 'CONTENT_LENGTH': '200'}
assert 'text/plain' == ContentType(environ)
assert '200' == ContentLength(environ)
ContentType.update(environ,'new/type')
assert 'new/type' == ContentType(environ)
ContentType.delete(environ)
- assert 'server/supplied' == ContentType(environ)
+ assert '' == ContentType(environ)
+ assert 'ignored/invalid' == environ['HTTP_CONTENT_TYPE']
def test_response_headers():
collection = [('via', 'bing')]
@@ -61,8 +63,8 @@ def test_cache_control():
headers = []
CacheControl.apply(headers,max_age=60)
assert 'public, max-age=60' == CacheControl(headers)
- assert Expires.time(headers) > time.time()
- assert Expires.time(headers) < time.time() + 60
+ assert Expires.parse(headers) > time.time()
+ assert Expires.parse(headers) < time.time() + 60
def test_content_disposition():
assert 'attachment' == ContentDisposition()
@@ -87,6 +89,20 @@ def test_content_disposition():
('Content-Disposition', 'attachment; filename="test.txt"')
]
+def test_range():
+ assert ('bytes',[(0,300)]) == Range.parse("bytes=0-300")
+ assert ('bytes',[(0,300)]) == Range.parse("bytes = -300")
+ assert ('bytes',[(0,None)]) == Range.parse("bytes= -")
+ assert ('bytes',[(0,None)]) == Range.parse("bytes=0 - ")
+ assert ('bytes',[(300,None)]) == Range.parse(" BYTES=300-")
+ assert ('bytes',[(4,5),(6,7)]) == Range.parse(" Bytes = 4 - 5,6 - 07 ")
+ assert ('bytes',[(0,5),(7,None)]) == Range.parse(" bytes=-5,7-")
+ assert ('bytes',[(0,5),(7,None)]) == Range.parse(" bytes=-5,7-")
+ assert ('bytes',[(0,5),(7,None)]) == Range.parse(" bytes=-5,7-")
+ assert None == Range.parse("")
+ assert None == Range.parse("bytes=0,300")
+ assert None == Range.parse("bytes=-7,5-")
+
def test_copy():
environ = {'HTTP_VIA':'bing', 'wsgi.version': '1.0' }
response_headers = []