From 855fe8da6602651768b645a38879ed77531b62c4 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 26 Mar 2020 21:41:04 +0100 Subject: [PATCH] exterminate! --- .gitignore | 1 + distbot/plugins/fun.py | 5 ++++- ...t_urlresolver_plugin.py => test_plugin.py} | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) rename tests/test_unit/{test_urlresolver_plugin.py => test_plugin.py} (52%) diff --git a/.gitignore b/.gitignore index b6e5ed3..3ee5e4d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ local_config.ini persistent_config.ini .idea distbot.egg-info +dist diff --git a/distbot/plugins/fun.py b/distbot/plugins/fun.py index 08bd2e6..fb636f5 100644 --- a/distbot/plugins/fun.py +++ b/distbot/plugins/fun.py @@ -171,7 +171,10 @@ class Doctor(Worker): description = "machines don't like the doctor." def parse_body(self, msg): - return Action(msg="ELIMINATE! ELIMINATE!") + if "doctor" in self.used_channel: + return Action(msg="EXTERMINATE! EXTERMINATE!") + else: + return Action(msg="ELIMINIEREN! ELIMINIEREN!") class Sick(Worker): diff --git a/tests/test_unit/test_urlresolver_plugin.py b/tests/test_unit/test_plugin.py similarity index 52% rename from tests/test_unit/test_urlresolver_plugin.py rename to tests/test_unit/test_plugin.py index 8b4fa97..9dc99b4 100644 --- a/tests/test_unit/test_urlresolver_plugin.py +++ b/tests/test_unit/test_plugin.py @@ -6,14 +6,18 @@ import pytest from distbot.common.action import Action +@pytest.fixture() +def deadworker(monkeypatch): + monkeypatch.setattr(Worker, "register_plugin", lambda x: None) + + @pytest.mark.parametrize( argnames='message, expected_action', argvalues=[ ('http://debianforum.de', Action(msg="Title: Trollspielwiese")), ] ) -def test_urlresolver(monkeypatch, message, expected_action): - monkeypatch.setattr(Worker, "register_plugin", lambda x: None) +def test_urlresolver(deadworker, monkeypatch, message, expected_action): import distbot.plugins.url as url monkeypatch.setattr(url, "extract_title", lambda x: "Trollspielwiese") @@ -21,3 +25,14 @@ def test_urlresolver(monkeypatch, message, expected_action): result = worker.parse_body(msg={"body": message}) assert result == expected_action + + +def test_doctor_multilingo(): + from distbot.plugins.fun import Doctor + + doc = Doctor("_") + doc.used_channel = ["call", "the", "doctor"] + assert Action(msg="EXTERMINATE! EXTERMINATE!") == doc.parse_body({"msg": "call the doctor!"}) + + doc.used_channel = ["der", "doktor", "hat", "gleich", "zeit"] + assert Action(msg="ELIMINIEREN! ELIMINIEREN!") == doc.parse_body({"msg": "der Doktor hat gleich zeit."}) -- 2.39.2