Exemplo n.º 1
0
def test_double_event_handler_attachment(connection):
    handler1 = DefaultHandler()
    handler2 = DefaultHandler()
    sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade')
    sub.set_event_handler(handler1)
    dxc.dxf_attach_listener(sub)
    symbols = ['AAPL', 'MSFT']
    dxc.dxf_add_symbols(sub, symbols)
    sub.set_event_handler(handler2)
    assert sub.get_event_handler() is handler2
    assert set(dxc.dxf_get_symbols(sub)) == set(symbols)
Exemplo n.º 2
0
    def _attach_default_listener(self):
        """
        Method to attach default listener. If event handler was not previously set, DefaultHandler will be initialized.

        Returns
        -------
        self: Subscription
        """
        if not self.get_event_handler():
            self.set_event_handler(DefaultHandler())
            simplefilter(action='ignore', category=FutureWarning)

        dxp.dxf_attach_listener(self.__sub)

        simplefilter(action='default', category=FutureWarning)

        return self