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):
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")
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."})