From 73f4f26da57239e5a134a01cbe82d44d34aa6b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Mon, 4 Jan 2016 02:36:15 +0100 Subject: [PATCH] more tests --- tests/test_jobqueue.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index 550e0acb3..0c2fe4d01 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -72,6 +72,9 @@ class UpdaterTest(BaseTest, unittest.TestCase): def job1(self, bot): self.result += 1 + def job2(self, bot): + raise Exception("Test Error") + def test_basic(self): print('Testing basic job queue function') self.jq.put(self.job1, 0.1) @@ -95,5 +98,22 @@ class UpdaterTest(BaseTest, unittest.TestCase): sleep(0.1) self.assertEqual(1, self.result) + def test_multiple(self): + print('Testing job queue with multiple jobs') + self.jq.put(self.job1, 0.1, repeat=False) + self.jq.put(self.job1, 0.2, repeat=False) + self.jq.put(self.job1, 0.4) + self.jq.start() + sleep(1) + self.assertEqual(4, self.result) + + def test_error(self): + print('Testing job queue starting twice with an erroneous job') + self.jq.put(self.job2, 0.1) + self.jq.put(self.job1, 0.2) + self.jq.start() + self.jq.start() + sleep(0.4) + self.assertEqual(1, self.result) if __name__ == '__main__': unittest.main()