summaryrefslogtreecommitdiff
path: root/tests/test_response.py
diff options
context:
space:
mode:
authorFrançois Labelle <quantum.omega@gmail.com>2015-04-22 21:16:41 -0400
committerFrançois Labelle <quantum.omega@gmail.com>2015-04-22 22:26:08 -0400
commit986bc215b4eb60945d74075ec465e1ba2c84767c (patch)
treef94fd94a5acdb9e9b7ee13f7b5e5cba3886c32c7 /tests/test_response.py
parent9b79f5f913fb1f07c68102a2279ed757a2a9abf6 (diff)
downloadwebob-986bc215b4eb60945d74075ec465e1ba2c84767c.tar.gz
Don't add a charset if none is specified and the content-type is JSON.
Diffstat (limited to 'tests/test_response.py')
-rw-r--r--tests/test_response.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_response.py b/tests/test_response.py
index d9c1cd3..6425a22 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -104,6 +104,7 @@ def test_set_response_status_code_generic_reason():
assert res.status_code == 299
assert res.status == '299 Success'
+
def test_content_type():
r = Response()
# default ctype and charset
@@ -121,6 +122,21 @@ def test_init_content_type_w_charset():
v = 'text/plain;charset=ISO-8859-1'
eq_(Response(content_type=v).headers['content-type'], v)
+def test_init_adds_default_charset_when_not_json():
+ content_type = 'text/plain'
+ expected = 'text/plain; charset=UTF-8'
+ eq_(Response(content_type=content_type).headers['content-type'], expected)
+
+def test_init_no_charset_when_json():
+ content_type = 'application/json'
+ expected = content_type
+ eq_(Response(content_type=content_type).headers['content-type'], expected)
+
+def test_init_keeps_specified_charset_when_json():
+ content_type = 'application/json;charset=ISO-8859-1'
+ expected = content_type
+ eq_(Response(content_type=content_type).headers['content-type'], expected)
+
def test_cookies():
res = Response()