def test_on_new_event(self): eun = EventUpdatesNamespace(self.environ, self.ns_name, self.request) eun.emit = Mock() eun.on_new_event("abc", "def") self.assertEqual(eun.emit.call_args[0][0], "new_event") self.assertEqual(eun.emit.call_args[0][1], "abc") self.assertEqual(eun.emit.call_args[0][2], "def")
def test_listener(self): eun = EventUpdatesNamespace(self.environ, self.ns_name, self.request) eun.process_event = Mock() room = "http://127.0.0.1:8001/project/PAM" eun.listener(room) self.redis.subscribe.assert_called_once_with("socketio_%s" % room) self.assertEqual(eun.process_event.call_args[0][0], "abcd")
def test_on_subscribe(self): eun = EventUpdatesNamespace(self.environ, self.ns_name, self.request) eun.spawn = Mock() eun.join = Mock() room = "http://127.0.0.1:8001/project/PAM" eun.on_subscribe(room) self.assertEqual(eun.room, room) self.assertEqual(eun.join.call_args[0][0], room) self.assertEqual(eun.spawn.call_args[0][0], eun.listener) self.assertEqual(eun.spawn.call_args[0][1], room)