]> git.aero2k.de Git - urlbot-v3.git/commitdiff
exterminate!
authorThorsten <mail@aero2k.de>
Thu, 26 Mar 2020 20:41:04 +0000 (21:41 +0100)
committerThorsten <mail@aero2k.de>
Thu, 26 Mar 2020 20:41:04 +0000 (21:41 +0100)
.gitignore
distbot/plugins/fun.py
tests/test_unit/test_plugin.py [moved from tests/test_unit/test_urlresolver_plugin.py with 52% similarity]

index b6e5ed3d5bf14e770657879293f3e5682625ef18..3ee5e4dc139c14a4de0f2c459aa01f2fb9dd695e 100644 (file)
@@ -2,3 +2,4 @@ local_config.ini
 persistent_config.ini
 .idea
 distbot.egg-info
+dist
index 08bd2e672e8afa90f7613036af540388744fe228..fb636f5b037958e2f1571035add9543210d802e5 100644 (file)
@@ -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):
similarity index 52%
rename from tests/test_unit/test_urlresolver_plugin.py
rename to tests/test_unit/test_plugin.py
index 8b4fa9703bff1ee59a4d8819a46daab9c7e5c69c..9dc99b4f2740bf5b7c8bf8f54b3cd0ca96755c6a 100644 (file)
@@ -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."})