Add tests for custom_contentviews example

This commit is contained in:
Shadab Zafar 2016-03-07 09:41:17 +05:30
parent 5eca2223d5
commit ba1cf18f42

View File

@ -8,6 +8,7 @@ from . import tservers, tutils
from examples import (
add_header,
custom_contentviews,
modify_form,
modify_querystring,
modify_response_body,
@ -72,4 +73,11 @@ def test_modify_response_body():
flow = tutils.tflow(resp=netutils.tresp(content="I <3 mitmproxy"))
modify_response_body.response(ctx, flow)
assert flow.response.content == "I <3 rocks"
assert flow.response.content == "I <3 rocks"
def test_custom_contentviews():
pig = custom_contentviews.ViewPigLatin()
_, fmt = pig("<html>test!</html>")
assert any('esttay!' in val[0][1] for val in fmt)
assert not pig("gobbledygook")