From e8553f966f63923d42e0ef380d82794d73f2637d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 18 Aug 2012 17:29:29 +1200 Subject: Further simplifcation and testing of contentviews. --- test/test_console_contentview.py | 58 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) (limited to 'test/test_console_contentview.py') 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" + "", + 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"]], ), - "" + "", + 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") -- cgit v1.2.3