diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-10-30 13:28:16 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-10-30 14:56:36 +1300 |
commit | 2b76db1272c1a37310e69852805fbeccccbe0032 (patch) | |
tree | e32c568c81795c7350dbaa9968a07d217150eeec /test | |
parent | b9eb1a34791d6d48f132fc09d5320edaa128dda4 (diff) | |
download | mitmproxy-2b76db1272c1a37310e69852805fbeccccbe0032.tar.gz mitmproxy-2b76db1272c1a37310e69852805fbeccccbe0032.tar.bz2 mitmproxy-2b76db1272c1a37310e69852805fbeccccbe0032.zip |
console: Port from state to view
First phase of the port - basic flow list and flow view functionality working.
More to come.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_view.py | 44 |
1 files changed, 19 insertions, 25 deletions
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="~~") |