From 8cb9561bf1e78a48ee0d7cb9fe63cdd108ac73e8 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Thu, 17 Oct 2019 23:18:00 -0500 Subject: [PATCH] duckhunt: Add tests for ignore integration --- tests/plugin_tests/test_duckhunt.py | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/plugin_tests/test_duckhunt.py b/tests/plugin_tests/test_duckhunt.py index cef2f6637..f5a92fc73 100644 --- a/tests/plugin_tests/test_duckhunt.py +++ b/tests/plugin_tests/test_duckhunt.py @@ -110,3 +110,41 @@ class Conn: assert duckhunt.killers('#channel', event, chan, conn, session) is None event.notice_doc.assert_called_once() + + +def test_ignore_integration(): + from plugins import duckhunt + event = MagicMock() + event.chan = "#chan" + event.mask = "nick!user@host" + event.host = "host" + + ignore_plugin = MagicMock() + + ignore_plugin.code.is_ignored.return_value = True + + plugins = { + 'core.ignore': ignore_plugin, + } + + def find_plugin(name): + return plugins.get(name) + + event.bot.plugin_manager.find_plugin = find_plugin + + conn = event.conn + conn.name = "testconn" + + tbl = duckhunt.get_state_table(conn.name, event.chan) + tbl.game_on = True + tbl.duck_status = 0 + + duckhunt.increment_msg_counter(event, conn) + + assert not tbl.masks + + ignore_plugin.code.is_ignored.return_value = False + + duckhunt.increment_msg_counter(event, conn) + + assert tbl.masks == [event.host]