summaryrefslogtreecommitdiffstats
path: root/tests/test_interactionManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-03-20 14:57:45 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-03-20 14:57:45 +0100
commit50d4df8b4d48b855bd18e9922355b7f3f2b4da4e (patch)
tree6301b05677a90cf86f131d5a7ae3f879b38e84d2 /tests/test_interactionManager.py
parentrenamed hooks to addons, new filemanager and database, many new api methods (diff)
downloadpyload-50d4df8b4d48b855bd18e9922355b7f3f2b4da4e.tar.xz
captcha decrypting for all plugin types, new interaction manager
Diffstat (limited to 'tests/test_interactionManager.py')
-rw-r--r--tests/test_interactionManager.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_interactionManager.py b/tests/test_interactionManager.py
new file mode 100644
index 000000000..920d84b9d
--- /dev/null
+++ b/tests/test_interactionManager.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+
+from unittest import TestCase
+from helper.Stubs import Core
+
+from module.Api import Input, Output
+from module.interaction.InteractionManager import InteractionManager
+
+class TestInteractionManager(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.core = Core()
+
+ def setUp(self):
+ self.im = InteractionManager(self.core)
+
+
+ def test_notifications(self):
+
+ n = self.im.createNotification("test", "notify")
+ assert self.im.getNotifications() == [n]
+
+ for i in range(10):
+ self.im.createNotification("title", "test")
+
+ assert len(self.im.getNotifications()) == 11
+
+
+ def test_captcha(self):
+ assert self.im.getTask() is None
+
+ t = self.im.newCaptchaTask("1", "", "")
+ assert t.output == Output.Captcha
+ self.im.handleTask(t)
+ assert t is self.im.getTask()
+
+ t2 = self.im.newCaptchaTask("2", "", "")
+ self.im.handleTask(t2)
+
+ assert self.im.getTask(Output.Query) is None
+ assert self.im.getTask() is t
+
+ self.im.removeTask(t)
+ assert self.im.getTask() is t2
+
+ self.im.getTaskByID(t2.iid)
+ assert self.im.getTask() is None
+
+
+ def test_query(self):
+ assert self.im.getTask() is None
+ t = self.im.newQueryTask(Input.Text, None, "text")
+ assert t.description == "text"
+ self.im.handleTask(t)
+
+ assert self.im.getTask(Output.Query) is t
+ assert self.im.getTask(Output.Captcha) is None \ No newline at end of file