def test_process_get_action_response(sm: SubscriptionManager):
    category = Category.MARKET
    events = [MarketEvents.ORDERS, MarketEvents.CANCELS]
    topics = ['ETH_AURA', 'ETH_ZRX']
    payload = dict(events=events, topics=topics)

    assert sm.subscriptions == {}

    sm._process_get_action_response(category, payload)

    assert sm.subscriptions == {}

    sm._process_subscribe_action_response(category, payload)

    payload['topics'] = ['ETH_SAN']
    old_events = sm.subscriptions[category].events
    sm._process_get_action_response(category, payload)

    assert sm.subscriptions[category].events == old_events
    assert sm.subscriptions[category].topics == ('ETH_SAN', )
def test_process_sub_response_get_handler(sm: SubscriptionManager):
    message = dict(
        result='success',
        request='subscribeToMarkets',
        payload=dict(action='get'),
    )

    sm._logger.error = Mock()
    sm._process_get_action_response = Mock()

    result = sm.process_sub_response(message)

    sm._process_get_action_response.assert_called_once_with(
        Category(message['request']), message['payload'])
    assert result is None