summaryrefslogtreecommitdiff
path: root/tests/test_httpheaders.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_httpheaders.py')
-rw-r--r--tests/test_httpheaders.py45
1 files changed, 21 insertions, 24 deletions
diff --git a/tests/test_httpheaders.py b/tests/test_httpheaders.py
index 7623c78..9db1396 100644
--- a/tests/test_httpheaders.py
+++ b/tests/test_httpheaders.py
@@ -1,34 +1,31 @@
from paste.httpheaders import *
+def test_environ():
+ environ = {'HTTP_VIA':'bing', 'wsgi.version': '1.0' }
+ assert 'bing' == Via(environ)
+
+def test_response_headers():
+ response_headers = [('via', 'bing')]
+ assert 'bing' == Via(response_headers)
+
def test_sorting():
# verify the HTTP_HEADERS are set with their canonical form
- sample = [HTTP_WWW_AUTHENTICATE, HTTP_VIA, HTTP_ACCEPT, HTTP_DATE,
- HTTP_ACCEPT_CHARSET, HTTP_AGE, HTTP_ALLOW, HTTP_CACHE_CONTROL,
- HTTP_CONTENT_ENCODING, HTTP_ETAG, HTTP_CONTENT_TYPE, HTTP_FROM,
- HTTP_EXPIRES, HTTP_RANGE, HTTP_UPGRADE, HTTP_VARY, HTTP_ALLOW]
+ sample = [WWWAuthenticate, Via, Accept, Date,
+ AcceptCharset, Age, Allow, CacheControl,
+ ContentEncoding, ETag, ContentType, From,
+ Expires, Range, Upgrade, Vary, Allow]
sample.sort()
- sample = [(x.category, str(x)) for x in sample]
+ sample = [str(x) for x in sample]
assert sample == [
# general headers first
- ('general', 'Cache-Control'),
- ('general', 'Date'),
- ('general', 'Upgrade'),
- ('general', 'Via'),
- # request and response
- ('request', 'Accept'),
- ('request', 'Accept-Charset'),
- ('response', 'Age'),
- ('response', 'ETag'), # ETag is odd case
- ('request', 'From'),
- ('request', 'Range'),
- ('response', 'Vary'),
- ('response', 'WWW-Authenticate'), # so is WWW-Authenticate
- # entity headers last
- ('entity', 'Allow'), # expected duplicate
- ('entity', 'Allow'),
- ('entity', 'Content-Encoding'),
- ('entity', 'Content-Type'),
- ('entity', 'Expires')]
+ 'Cache-Control', 'Date', 'Upgrade', 'Via',
+ # request headers next
+ 'Accept', 'Accept-Charset', 'From', 'Range',
+ # response headers following
+ 'Age', 'ETag', 'Vary', 'WWW-Authenticate',
+ # entity headers (/w expected duplicate)
+ 'Allow', 'Allow', 'Content-Encoding', 'Content-Type', 'Expires'
+ ]
def test_normalize():
response_headers = [