def test_unsubscribe_closes_transport(self): trans = mock.Mock() sub = FSubscription("topic", trans) sub.unsubscribe() trans.unsubscribe.assert_called_with()
async def subscribe_TimeLeft(self, TimeLeft_handler): """ TimeLeft_handler: function which takes FContext and Minutes """ op = 'TimeLeft' prefix = 'v1.music.' topic = '{}AlbumWinners{}{}'.format(prefix, self._DELIMITER, op) transport, protocol_factory = self._provider.new_subscriber() await transport.subscribe(topic, self._recv_TimeLeft(protocol_factory, op, TimeLeft_handler)) return FSubscription(topic, transport)
def subscribe_ContestStart(self, ContestStart_handler): """ ContestStart_handler: function which takes FContext and list<Album> """ op = 'ContestStart' prefix = 'v1.music.' topic = '{}AlbumWinners{}{}'.format(prefix, self._DELIMITER, op) transport, protocol_factory = self._provider.new_subscriber() yield transport.subscribe(topic, self._recv_ContestStart(protocol_factory, op, ContestStart_handler)) raise gen.Return(FSubscription(topic, transport))
def subscribe_SomeInt(self, user, SomeInt_handler): """ Args: user: string SomeInt_handler: function which takes FContext and i64 """ op = 'SomeInt' prefix = 'foo.{}.'.format(user) topic = '{}Events{}{}'.format(prefix, self._DELIMITER, op) transport, protocol_factory = self._provider.new_subscriber() yield transport.subscribe(topic, self._recv_SomeInt(protocol_factory, op, SomeInt_handler)) raise gen.Return(FSubscription(topic, transport))
async def subscribe_SomeList(self, user, SomeList_handler): """ Args: user: string SomeList_handler: function which takes FContext and list<map<id,Event>> """ op = 'SomeList' prefix = 'foo.{}.'.format(user) topic = '{}Events{}{}'.format(prefix, self._DELIMITER, op) transport, protocol_factory = self._provider.new_subscriber() await transport.subscribe(topic, self._recv_SomeList(protocol_factory, op, SomeList_handler)) return FSubscription(topic, transport)
def subscribe_EventCreated(self, user, EventCreated_handler): """ This is a docstring. Args: user: string EventCreated_handler: function which takes FContext and Event """ op = 'EventCreated' prefix = 'foo.{}.'.format(user) topic = '{}Events{}{}'.format(prefix, self._DELIMITER, op) transport, protocol_factory = self._provider.new_subscriber() yield transport.subscribe(topic, self._recv_EventCreated(protocol_factory, op, EventCreated_handler)) raise gen.Return(FSubscription(topic, transport))
def test_get_topic(self): trans = mock.Mock() sub = FSubscription("topic", trans) self.assertEquals("topic", sub.get_topic())