From 2b76db1272c1a37310e69852805fbeccccbe0032 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 30 Oct 2016 13:28:16 +1300 Subject: console: Port from state to view First phase of the port - basic flow list and flow view functionality working. More to come. --- test/mitmproxy/addons/test_view.py | 44 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index 2715fd6a..e8d6fb07 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -1,6 +1,8 @@ from mitmproxy.test import tflow from mitmproxy.addons import view from mitmproxy import flowfilter +from mitmproxy import options +from mitmproxy.test import taddons from .. import tutils @@ -31,6 +33,10 @@ def test_simple(): assert list(v) == [f, f3, f2] assert len(v._store) == 3 + v.clear() + assert len(v) == 0 + assert len(v._store) == 0 + def tft(*, method="get", start=0): f = tflow.tflow() @@ -236,31 +242,6 @@ def test_focus(): assert f.index is None -def test_focus_nextprev(): - v = view.View() - # Nops on an empty view - v.focus.next() - v.focus.prev() - - # Nops on a single-flow view - v.add(tft(start=0)) - assert v.focus.flow == v[0] - v.focus.next() - assert v.focus.flow == v[0] - v.focus.prev() - assert v.focus.flow == v[0] - - v.add(tft(start=1)) - v.focus.next() - assert v.focus.flow == v[1] - v.focus.next() - assert v.focus.flow == v[1] - v.focus.prev() - assert v.focus.flow == v[0] - v.focus.prev() - assert v.focus.flow == v[0] - - def test_settings(): v = view.View() f = tft() @@ -274,3 +255,16 @@ def test_settings(): v.remove(f) tutils.raises(KeyError, v.settings.__getitem__, f) assert not v.settings.keys() + + +class Options(options.Options): + def __init__(self, *, filter=None, **kwargs): + self.filter = filter + super().__init__(**kwargs) + + +def test_configure(): + v = view.View() + with taddons.context(options=Options()) as tctx: + tctx.configure(v, filter="~q") + tutils.raises("invalid interception filter", tctx.configure, v, filter="~~") -- cgit v1.2.3