thirdparty/google_appengine/lib/webob/tests/test_response.py
changeset 109 620f9b141567
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thirdparty/google_appengine/lib/webob/tests/test_response.py	Tue Aug 26 21:49:54 2008 +0000
@@ -0,0 +1,37 @@
+from webob import *
+
+def simple_app(environ, start_response):
+    start_response('200 OK', [
+        ('Content-Type', 'text/html; charset=utf8'),
+        ])
+    return ['OK']
+
+def test_response():
+    req = Request.blank('/')
+    res = req.get_response(simple_app)
+    assert res.status == '200 OK'
+    assert res.status_int == 200
+    assert res.body == "OK"
+    assert res.charset == 'utf8'
+    assert res.content_type == 'text/html'
+    res.status = 404
+    assert res.status == '404 Not Found'
+    assert res.status_int == 404
+    res.body = 'Not OK'
+    assert ''.join(res.app_iter) == 'Not OK'
+    res.charset = 'iso8859-1'
+    assert res.headers['content-type'] == 'text/html; charset=iso8859-1'
+    res.content_type = 'text/xml'
+    assert res.headers['content-type'] == 'text/xml; charset=iso8859-1'
+    res.headers = {'content-type': 'text/html'}
+    assert res.headers['content-type'] == 'text/html'
+    assert res.headerlist == [('content-type', 'text/html')]
+    res.set_cookie('x', 'y')
+    assert res.headers['set-cookie'].strip(';') == 'x=y; Path=/'
+    res = Response('a body', '200 OK', content_type='text/html')
+    res.encode_content()
+    assert res.content_encoding == 'gzip'
+    assert res.body == '\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xffKTH\xcaO\xa9\x04\x00\xf6\x86GI\x06\x00\x00\x00'
+    res.decode_content()
+    assert res.content_encoding is None
+    assert res.body == 'a body'