diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-08-18 17:29:29 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-08-18 17:29:29 +1200 |
commit | e8553f966f63923d42e0ef380d82794d73f2637d (patch) | |
tree | bda83708f6e058364fdfa918b430261008cad260 /test/test_console_contentview.py | |
parent | 11c63dcb9f2e88f17704898efc16fb289d877196 (diff) | |
download | mitmproxy-e8553f966f63923d42e0ef380d82794d73f2637d.tar.gz mitmproxy-e8553f966f63923d42e0ef380d82794d73f2637d.tar.bz2 mitmproxy-e8553f966f63923d42e0ef380d82794d73f2637d.zip |
Further simplifcation and testing of contentviews.
Diffstat (limited to 'test/test_console_contentview.py')
-rw-r--r-- | test/test_console_contentview.py | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py index 04f72a17..d2ab72dc 100644 --- a/test/test_console_contentview.py +++ b/test/test_console_contentview.py @@ -11,61 +11,42 @@ class TestContentView: cv.trailer(cv.VIEW_CUTOFF + 10, txt, cv.VIEW_CUTOFF) assert txt - def test_get_view_func(self): - f = cv.get_view_func( - cv.get("Hex"), + def test_view_auto(self): + v = cv.ViewAuto() + f = v( flow.ODictCaseless(), - "foo" - ) - assert f.name == "Hex" - - f = cv.get_view_func( - cv.get("Auto"), - flow.ODictCaseless(), - "foo" + "foo", + 1000 ) - assert f.name == "Raw" + assert f[0] == "Raw" - f = cv.get_view_func( - cv.get("Auto"), + f = v( flow.ODictCaseless( [["content-type", "text/html"]], ), - "foo" + "<html></html>", + 1000 ) - assert f.name == "HTML" + assert f[0] == "HTML" - f = cv.get_view_func( - cv.get("Auto"), + f = v( flow.ODictCaseless( [["content-type", "text/flibble"]], ), - "foo" + "foo", + 1000 ) - assert f.name == "Raw" + assert f[0] == "Raw" - f = cv.get_view_func( - cv.get("Auto"), + f = v( flow.ODictCaseless( [["content-type", "text/flibble"]], ), - "<xml></xml>" + "<xml></xml>", + 1000 ) - assert f.name == "XML" - - try: - import pyamf + assert f[0].startswith("XML") - f = cv.get_view_func( - cv.get("Auto"), - flow.ODictCaseless( - [["content-type", "application/x-amf"]], - ), - "" - ) - assert f.name == "AMF" - except ImportError: - pass def test_view_urlencoded(self): d = utils.urlencode([("one", "two"), ("three", "four")]) @@ -223,3 +204,6 @@ Larry assert "decoded gzip" in r[0] assert "Raw" in r[0] + +def test_get_by_shortcut(): + assert cv.get_by_shortcut("h") |