view: show a message if we remove more than one flow from view

This commit is contained in:
Aldo Cortesi 2017-06-13 10:32:47 +12:00
parent 56eb0441da
commit 88832f92a3
2 changed files with 12 additions and 0 deletions

View File

@ -389,6 +389,8 @@ class View(collections.Sequence):
self.sig_view_remove.send(self, flow=f) self.sig_view_remove.send(self, flow=f)
del self._store[f.id] del self._store[f.id]
self.sig_store_remove.send(self, flow=f) self.sig_store_remove.send(self, flow=f)
if len(flows) > 1:
ctx.log.alert("Removed %s flows" % len(flows))
@command.command("view.resolve") @command.command("view.resolve")
def resolve(self, spec: str) -> typing.Sequence[mitmproxy.flow.Flow]: def resolve(self, spec: str) -> typing.Sequence[mitmproxy.flow.Flow]:

View File

@ -262,6 +262,16 @@ def test_duplicate():
assert v.focus.index == 2 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(): def test_setgetval():
v = view.View() v = view.View()
with taddons.context(): with taddons.context():