aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-08-17 21:40:52 +0800
committerMatthew Shao <me@matshao.com>2017-08-17 21:40:52 +0800
commitd008f179c3e6fa620c6babc6cedf8e7df9093827 (patch)
tree3a914648a4761515433b2e100de3e567095c6f0b
parentaf30930ae8ea10b1be3d062cc12481d37c377aa6 (diff)
downloadmitmproxy-d008f179c3e6fa620c6babc6cedf8e7df9093827.tar.gz
mitmproxy-d008f179c3e6fa620c6babc6cedf8e7df9093827.tar.bz2
mitmproxy-d008f179c3e6fa620c6babc6cedf8e7df9093827.zip
[web] Static_viewer coverage ++.
-rw-r--r--test/mitmproxy/addons/test_static_viewer.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/mitmproxy/addons/test_static_viewer.py b/test/mitmproxy/addons/test_static_viewer.py
index 7e34a9fc..bb2b6777 100644
--- a/test/mitmproxy/addons/test_static_viewer.py
+++ b/test/mitmproxy/addons/test_static_viewer.py
@@ -1,4 +1,5 @@
import json
+from unittest import mock
from mitmproxy.test import taddons
from mitmproxy.test import tflow
@@ -32,9 +33,11 @@ def test_save_flows(tmpdir):
assert tmpdir.join('flows.json').read() == json.dumps([flow_to_json(f) for f in flows])
-def test_save_flows_content(tmpdir):
+@mock.patch('mitmproxy.ctx.log')
+def test_save_flows_content(ctx, tmpdir):
flows = [tflow.tflow(req=True, resp=None), tflow.tflow(req=True, resp=True)]
- static_viewer.save_flows_content(tmpdir, flows)
+ with mock.patch('time.time', mock.Mock(side_effect=[1, 2, 2] * 4)):
+ static_viewer.save_flows_content(tmpdir, flows)
flows_path = tmpdir.join('flows')
assert len(flows_path.listdir()) == len(flows)
for p in flows_path.listdir():