diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-06 01:37:19 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-06 01:37:19 +0200 |
commit | eb2334c6cb7c9ab9c260bc609ae43fb53d441f6f (patch) | |
tree | a6b263b856bd035ac154b45fe7e91706918b25f3 /test/test_console_contentview.py | |
parent | 853cd810757a02252402da22ae77cab77c5a3fb6 (diff) | |
parent | a8d931089c9ecf450b69321706825cf694c1c08e (diff) | |
download | mitmproxy-eb2334c6cb7c9ab9c260bc609ae43fb53d441f6f.tar.gz mitmproxy-eb2334c6cb7c9ab9c260bc609ae43fb53d441f6f.tar.bz2 mitmproxy-eb2334c6cb7c9ab9c260bc609ae43fb53d441f6f.zip |
Merge branch 'master' into readthedocs
Diffstat (limited to 'test/test_console_contentview.py')
-rw-r--r-- | test/test_console_contentview.py | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py index d1a6180f..6a93346a 100644 --- a/test/test_console_contentview.py +++ b/test/test_console_contentview.py @@ -1,11 +1,13 @@ import os from nose.plugins.skip import SkipTest +from netlib.http import Headers + if os.name == "nt": raise SkipTest("Skipped on Windows.") import sys import netlib.utils -from netlib import odict, encoding +from netlib import encoding import libmproxy.console.contentview as cv from libmproxy import utils, flow @@ -33,34 +35,28 @@ class TestContentView: def test_view_auto(self): v = cv.ViewAuto() f = v( - odict.ODictCaseless(), + Headers(), "foo", 1000 ) assert f[0] == "Raw" f = v( - odict.ODictCaseless( - [["content-type", "text/html"]], - ), + Headers(content_type="text/html"), "<html></html>", 1000 ) assert f[0] == "HTML" f = v( - odict.ODictCaseless( - [["content-type", "text/flibble"]], - ), + Headers(content_type="text/flibble"), "foo", 1000 ) assert f[0] == "Raw" f = v( - odict.ODictCaseless( - [["content-type", "text/flibble"]], - ), + Headers(content_type="text/flibble"), "<xml></xml>", 1000 ) @@ -168,28 +164,22 @@ Content-Disposition: form-data; name="submit-name" Larry --AaB03x """.strip() - h = odict.ODictCaseless( - [("Content-Type", "multipart/form-data; boundary=AaB03x")] - ) + h = Headers(content_type="multipart/form-data; boundary=AaB03x") assert view(h, v, 1000) - h = odict.ODictCaseless() + h = Headers() assert not view(h, v, 1000) - h = odict.ODictCaseless( - [("Content-Type", "multipart/form-data")] - ) + h = Headers(content_type="multipart/form-data") assert not view(h, v, 1000) - h = odict.ODictCaseless( - [("Content-Type", "unparseable")] - ) + h = Headers(content_type="unparseable") assert not view(h, v, 1000) def test_get_content_view(self): r = cv.get_content_view( cv.get("Raw"), - [["content-type", "application/json"]], + Headers(content_type="application/json"), "[1, 2, 3]", 1000, False @@ -198,7 +188,7 @@ Larry r = cv.get_content_view( cv.get("Auto"), - [["content-type", "application/json"]], + Headers(content_type="application/json"), "[1, 2, 3]", 1000, False @@ -207,7 +197,7 @@ Larry r = cv.get_content_view( cv.get("Auto"), - [["content-type", "application/json"]], + Headers(content_type="application/json"), "[1, 2", 1000, False @@ -216,7 +206,7 @@ Larry r = cv.get_content_view( cv.get("AMF"), - [], + Headers(), "[1, 2", 1000, False @@ -225,10 +215,10 @@ Larry r = cv.get_content_view( cv.get("Auto"), - [ - ["content-type", "application/json"], - ["content-encoding", "gzip"] - ], + Headers( + content_type="application/json", + content_encoding="gzip" + ), encoding.encode('gzip', "[1, 2, 3]"), 1000, False @@ -238,10 +228,10 @@ Larry r = cv.get_content_view( cv.get("XML"), - [ - ["content-type", "application/json"], - ["content-encoding", "gzip"] - ], + Headers( + content_type="application/json", + content_encoding="gzip" + ), encoding.encode('gzip', "[1, 2, 3]"), 1000, False |