From ce5262adef147c6ddcea40deb7c28b45679982d1 Mon Sep 17 00:00:00 2001 From: John Carr Date: Sun, 7 Sep 2014 21:32:08 +0100 Subject: [PATCH] pubbot.dispatch tests --- pubbot/tests.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pubbot/tests.py b/pubbot/tests.py index 595d0a587..3e2adc1dd 100644 --- a/pubbot/tests.py +++ b/pubbot/tests.py @@ -4,12 +4,31 @@ from django.core.cache import caches +from pubbot import dispatch from pubbot import ratelimit from pubbot.state import Machine, State, Transition from pubbot.service import BaseService, TaskService from pubbot.utils import force_str, force_bytes +class TestDispatch(unittest.TestCase): + + def test_dispatch(self): + test_signal = dispatch.Signal() + a = mock.Mock() + b = mock.Mock() + b.side_effect = RuntimeError("Fake error") + + test_signal.connect(b) + test_signal.connect(a) + + retval = test_signal.send(hello="hello") + self.assertEqual(retval[0], (a, a.return_value)) + self.assertEqual(len(retval), 1) + + a.assert_called_with(signal=test_signal, sender=None, hello="hello") + + class TestRateLimitUtils(unittest.TestCase): def test_get_rate_1000_s(self):