summaryrefslogtreecommitdiff
path: root/tests/test_response.py
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2016-01-28 16:39:43 -0700
committerBert JW Regeer <bertjw@regeer.org>2016-01-28 16:39:43 -0700
commit25a62c1c5c8599cd802d1dfe79f881ca1eac05d6 (patch)
treef8d1514384cba6796308d191806402055d32947b /tests/test_response.py
parent619621515dfaa9781f2053704a8f5a6776be168c (diff)
parent986bc215b4eb60945d74075ec465e1ba2c84767c (diff)
downloadwebob-25a62c1c5c8599cd802d1dfe79f881ca1eac05d6.tar.gz
Merge '#197' of quantum-omega into bugfix/nocharset
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 8783792..c0bfe79 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()