aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/test_addonmanager.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/mitmproxy/test_addonmanager.py')
-rw-r--r--test/mitmproxy/test_addonmanager.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/test/mitmproxy/test_addonmanager.py b/test/mitmproxy/test_addonmanager.py
index 796ae1bd..a1f0a943 100644
--- a/test/mitmproxy/test_addonmanager.py
+++ b/test/mitmproxy/test_addonmanager.py
@@ -15,8 +15,8 @@ from mitmproxy.test import tflow
class TAddon:
def __init__(self, name, addons=None):
self.name = name
- self.tick = True
- self.custom_called = False
+ self.response = True
+ self.running_called = False
if addons:
self.addons = addons
@@ -30,12 +30,12 @@ class TAddon:
def done(self):
pass
- def event_custom(self):
- self.custom_called = True
+ def running(self):
+ self.running_called = True
class THalt:
- def event_custom(self):
+ def running(self):
raise exceptions.AddonHalt
@@ -47,7 +47,7 @@ class AOption:
def test_command():
with taddons.context() as tctx:
tctx.master.addons.add(TAddon("test"))
- assert tctx.master.commands.call("test.command") == "here"
+ assert tctx.master.commands.execute("test.command") == "here"
def test_halt():
@@ -59,12 +59,13 @@ def test_halt():
a.add(halt)
a.add(end)
- a.trigger("custom")
- assert not end.custom_called
+ assert not end.running_called
+ a.trigger("running")
+ assert not end.running_called
a.remove(halt)
- a.trigger("custom")
- assert end.custom_called
+ a.trigger("running")
+ assert end.running_called
@pytest.mark.asyncio
@@ -126,13 +127,17 @@ async def test_simple():
assert not a.chain
a.add(TAddon("one"))
+
+ a.trigger("nonexistent")
+ assert await tctx.master.await_log("unknown event")
+
a.trigger("running")
- a.trigger("tick")
+ a.trigger("response")
assert await tctx.master.await_log("not callable")
tctx.master.clear()
- a.get("one").tick = addons
- a.trigger("tick")
+ a.get("one").response = addons
+ a.trigger("response")
assert not await tctx.master.await_log("not callable")
a.remove(a.get("one"))
@@ -140,8 +145,8 @@ async def test_simple():
ta = TAddon("one")
a.add(ta)
- a.trigger("custom")
- assert ta.custom_called
+ a.trigger("running")
+ assert ta.running_called
assert ta in a
@@ -174,11 +179,11 @@ def test_nesting():
assert a.get("three")
assert a.get("four")
- a.trigger("custom")
- assert a.get("one").custom_called
- assert a.get("two").custom_called
- assert a.get("three").custom_called
- assert a.get("four").custom_called
+ a.trigger("running")
+ assert a.get("one").running_called
+ assert a.get("two").running_called
+ assert a.get("three").running_called
+ assert a.get("four").running_called
a.remove(a.get("three"))
assert not a.get("three")