From f1662cbfd7e2d6064d8a1fde22b6f3d288766f04 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 23 Nov 2016 00:23:36 +0100 Subject: [PATCH] add eventstore tests --- test/mitmproxy/addons/test_evenstore.py | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/mitmproxy/addons/test_evenstore.py diff --git a/test/mitmproxy/addons/test_evenstore.py b/test/mitmproxy/addons/test_evenstore.py new file mode 100644 index 000000000..78eb32877 --- /dev/null +++ b/test/mitmproxy/addons/test_evenstore.py @@ -0,0 +1,32 @@ +import mock +from mitmproxy import log +from mitmproxy.addons import eventstore + + +def test_simple(): + store = eventstore.EventStore() + assert not store.data + + sig_add = mock.Mock(spec=lambda: 42) + sig_refresh = mock.Mock(spec=lambda: 42) + store.sig_add.connect(sig_add) + store.sig_refresh.connect(sig_refresh) + + assert not sig_add.called + assert not sig_refresh.called + + # test .log() + store.log(log.LogEntry("test", "info")) + assert store.data + + assert sig_add.called + assert not sig_refresh.called + + # test .clear() + sig_add.reset_mock() + + store.clear() + assert not store.data + + assert not sig_add.called + assert sig_refresh.called