示例#1
0
    def test_unsubscribe(self):
        """Test that a handler will unregister a subscriber via a requestor's
        connection id.
        """
        mock_event_broadcaster = Mock()
        handler = ClientEventsUnsubscribeHandler(mock_event_broadcaster)

        request = \
            events_pb2.ClientEventsUnsubscribeRequest().SerializeToString()

        response = handler.handle('test_conn_id', request)

        mock_event_broadcaster.disable_subscriber.assert_called_with(
            'test_conn_id')
        mock_event_broadcaster.remove_subscriber.assert_called_with(
            'test_conn_id')

        self.assertEqual(HandlerStatus.RETURN, response.status)
        self.assertEqual(events_pb2.ClientEventsUnsubscribeResponse.OK,
                         response.message_out.status)
示例#2
0
 def _unsubscribe(self):
     request = events_pb2.ClientEventsUnsubscribeRequest()
     response = self.stream.send(
         validator_pb2.Message.CLIENT_EVENTS_UNSUBSCRIBE_REQUEST,
         request.SerializeToString()).result()
     return response