From 88832f92a35cacc0d80bffa477d9ffb0e2bee97e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 13 Jun 2017 10:32:47 +1200 Subject: [PATCH] view: show a message if we remove more than one flow from view --- mitmproxy/addons/view.py | 2 ++ test/mitmproxy/addons/test_view.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index aa3e11edb..d43194681 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -389,6 +389,8 @@ class View(collections.Sequence): self.sig_view_remove.send(self, flow=f) del self._store[f.id] self.sig_store_remove.send(self, flow=f) + if len(flows) > 1: + ctx.log.alert("Removed %s flows" % len(flows)) @command.command("view.resolve") def resolve(self, spec: str) -> typing.Sequence[mitmproxy.flow.Flow]: diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index d5a3a4562..03b2c8dd1 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -262,6 +262,16 @@ def test_duplicate(): assert v.focus.index == 2 +def test_remove(): + v = view.View() + with taddons.context(): + f = [tflow.tflow(), tflow.tflow() ] + v.add(f) + assert len(v) == 2 + v.remove(f) + assert len(v) == 0 + + def test_setgetval(): v = view.View() with taddons.context():