aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-11 15:31:25 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-11 15:31:25 +0200
commit02d80631dc1efcc1ef7d25b21c40c2327a32f49b (patch)
treefb04081aedb8e1cbd6529b95e46a659222f4f587 /test
parentdd414e485212e3cab612a66d5d858c1a766ace04 (diff)
parent47602dc1a5949a41535bc562adb83279f33f0b73 (diff)
downloadmitmproxy-02d80631dc1efcc1ef7d25b21c40c2327a32f49b.tar.gz
mitmproxy-02d80631dc1efcc1ef7d25b21c40c2327a32f49b.tar.bz2
mitmproxy-02d80631dc1efcc1ef7d25b21c40c2327a32f49b.zip
Merge pull request #764 from mitmproxy/contentviews
Extract Content Views from Console
Diffstat (limited to 'test')
-rw-r--r--test/test_console_common.py2
-rw-r--r--test/test_contentview.py (renamed from test/test_console_contentview.py)31
2 files changed, 14 insertions, 19 deletions
diff --git a/test/test_console_common.py b/test/test_console_common.py
index 57cbef98..459539c5 100644
--- a/test/test_console_common.py
+++ b/test/test_console_common.py
@@ -3,10 +3,8 @@ from nose.plugins.skip import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")
-from netlib import encoding
import libmproxy.console.common as common
-from libmproxy import utils, flow
import tutils
diff --git a/test/test_console_contentview.py b/test/test_contentview.py
index 6a93346a..ec1b4930 100644
--- a/test/test_console_contentview.py
+++ b/test/test_contentview.py
@@ -1,16 +1,12 @@
-import os
-from nose.plugins.skip import SkipTest
+from libmproxy.exceptions import ContentViewException
from netlib.http import Headers
-if os.name == "nt":
- raise SkipTest("Skipped on Windows.")
import sys
import netlib.utils
from netlib import encoding
-import libmproxy.console.contentview as cv
-from libmproxy import utils, flow
+import libmproxy.contentview as cv
import tutils
try:
@@ -26,11 +22,11 @@ except:
class TestContentView:
def test_trailer(self):
- txt = []
- cv.trailer(5, txt, 1000)
- assert not txt
- cv.trailer(cv.VIEW_CUTOFF + 10, txt, cv.VIEW_CUTOFF)
- assert txt
+ txt = "X"*10
+ lines = cv.trailer(txt, 1000)
+ assert not list(lines)
+ lines = cv.trailer(txt, 5)
+ assert list(lines)
def test_view_auto(self):
v = cv.ViewAuto()
@@ -124,16 +120,16 @@ class TestContentView:
result = v([], 'a', 100)
if cssutils:
- assert len(result[1]) == 0
+ assert len(list(result[1])) == 0
else:
- assert len(result[1]) == 1
+ assert len(list(result[1])) == 1
result = v([], fixture_1, 100)
if cssutils:
- assert len(result[1]) > 1
+ assert len(list(result[1])) > 1
else:
- assert len(result[1]) == 1
+ assert len(list(result[1])) == 1
def test_view_hex(self):
v = cv.ViewHex()
@@ -204,14 +200,15 @@ Larry
)
assert "Raw" in r[0]
- r = cv.get_content_view(
+ tutils.raises(
+ ContentViewException,
+ cv.get_content_view,
cv.get("AMF"),
Headers(),
"[1, 2",
1000,
False
)
- assert "Raw" in r[0]
r = cv.get_content_view(
cv.get("Auto"),