aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUjjwal Verma <ujjwalverma1111@gmail.com>2017-05-17 11:04:43 +0530
committerUjjwal Verma <ujjwalverma1111@gmail.com>2017-05-17 11:04:43 +0530
commit8eea05fcafde2410e6af0746c09a05c6d8d5a3e9 (patch)
tree55b57771139b2797cf96f47312d03265770ecdaa
parentca46b1e340750859881347ead92a64ed05105d25 (diff)
downloadmitmproxy-8eea05fcafde2410e6af0746c09a05c6d8d5a3e9.tar.gz
mitmproxy-8eea05fcafde2410e6af0746c09a05c6d8d5a3e9.tar.bz2
mitmproxy-8eea05fcafde2410e6af0746c09a05c6d8d5a3e9.zip
Increase contentviews api coverage
-rw-r--r--test/mitmproxy/contentviews/test_api.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/mitmproxy/contentviews/test_api.py b/test/mitmproxy/contentviews/test_api.py
index 95d83af9..c072c86f 100644
--- a/test/mitmproxy/contentviews/test_api.py
+++ b/test/mitmproxy/contentviews/test_api.py
@@ -9,23 +9,28 @@ from mitmproxy.test import tutils
class TestContentView(contentviews.View):
name = "test"
- prompt = ("t", "test")
+ prompt = ("test", "t")
content_types = ["test/123"]
def test_add_remove():
tcv = TestContentView()
contentviews.add(tcv)
+ assert tcv in contentviews.views
# repeated addition causes exception
- with pytest.raises(ContentViewException):
+ with pytest.raises(ContentViewException, match="Duplicate view"):
contentviews.add(tcv)
+ tcv2 = TestContentView()
+ tcv2.name = "test2"
+ tcv2.prompt = ("test2", "t")
# Same shortcut doesn't work either.
- with pytest.raises(ContentViewException):
- contentviews.add(TestContentView())
+ with pytest.raises(ContentViewException, match="Duplicate view shortcut"):
+ contentviews.add(tcv2)
contentviews.remove(tcv)
+ assert tcv not in contentviews.views
def test_get_content_view():
@@ -43,6 +48,7 @@ def test_get_content_view():
headers=Headers(content_type="application/json")
)
assert desc == "JSON"
+ assert list(lines)
desc, lines, err = contentviews.get_content_view(
contentviews.get("JSON"),
@@ -84,3 +90,4 @@ def test_get_message_content_view():
def test_get_by_shortcut():
assert contentviews.get_by_shortcut("s")
+ assert not contentviews.get_by_shortcut("b")