Beispiel #1
0
def test_exchange_query_balances_async(rotkehlchen_api_server_with_exchanges):
    """Test that using the exchange balances query endpoint works fine for async calls"""
    # async query balances of one specific exchange
    server = rotkehlchen_api_server_with_exchanges
    binance = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'binance']

    binance_patch = patch_binance_balances_query(binance)
    with binance_patch:
        response = requests.get(api_url_for(
            server,
            "named_exchanges_balances_resource",
            name='binance',
        ),
                                json={'async_query': True})
        task_id = assert_ok_async_response(response)
        outcome = wait_for_async_task(server, task_id)
    assert_binance_balances_result(outcome['result'])

    # async query of one exchange with querystring parameters
    poloniex = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'poloniex']

    poloniex_patch = patch_poloniex_balances_query(poloniex)
    with poloniex_patch:
        response = requests.get(
            api_url_for(
                server,
                "named_exchanges_balances_resource",
                name='poloniex',
            ) + '?async_query=true')
        task_id = assert_ok_async_response(response)
        outcome = wait_for_async_task(server, task_id)
    assert_poloniex_balances_result(outcome['result'])

    # async query balances of all setup exchanges
    with binance_patch, poloniex_patch:
        response = requests.get(
            api_url_for(server, "exchangebalancesresource"),
            json={'async_query': True},
        )
        task_id = assert_ok_async_response(response)
        outcome = wait_for_async_task(server, task_id)
    result = outcome['result']
    assert_binance_balances_result(result['binance'])
    assert_poloniex_balances_result(result['poloniex'])
Beispiel #2
0
def test_exchange_query_balances(rotkehlchen_api_server_with_exchanges):
    """Test that using the exchange balances query endpoint works fine"""
    async_query = random.choice([False, True])
    # query balances of one specific exchange
    server = rotkehlchen_api_server_with_exchanges
    binance = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'binance']

    binance_patch = patch_binance_balances_query(binance)
    with binance_patch:
        response = requests.get(api_url_for(
            server,
            "named_exchanges_balances_resource",
            name='binance',
        ),
                                json={'async_query': async_query})
        if async_query:
            task_id = assert_ok_async_response(response)
            outcome = wait_for_async_task_with_result(server, task_id)
        else:
            outcome = assert_proper_response_with_result(response)
    assert_binance_balances_result(outcome)

    # query balances of all setup exchanges
    poloniex = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'poloniex']

    poloniex_patch = patch_poloniex_balances_query(poloniex)
    with binance_patch, poloniex_patch:
        response = requests.get(
            api_url_for(server, "exchangebalancesresource"),
            json={'async_query': async_query},
        )
        if async_query:
            task_id = assert_ok_async_response(response)
            result = wait_for_async_task_with_result(server, task_id)
        else:
            result = assert_proper_response_with_result(response)

    assert_binance_balances_result(result['binance'])
    assert_poloniex_balances_result(result['poloniex'])
Beispiel #3
0
def test_exchange_query_balances(rotkehlchen_api_server_with_exchanges):
    """Test that using the exchange balances query endpoint works fine"""

    # query balances of one specific exchange
    server = rotkehlchen_api_server_with_exchanges
    binance = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'binance']

    binance_patch = patch_binance_balances_query(binance)
    with binance_patch:
        response = requests.get(
            api_url_for(
                server,
                "named_exchanges_balances_resource",
                name='binance',
            ))
    assert_proper_response(response)
    json_data = response.json()
    assert json_data['message'] == ''
    result = json_data['result']
    assert_binance_balances_result(json_data['result'])

    # query balances of all setup exchanges
    poloniex = server.rest_api.rotkehlchen.exchange_manager.connected_exchanges[
        'poloniex']

    poloniex_patch = patch_poloniex_balances_query(poloniex)
    with binance_patch, poloniex_patch:
        response = requests.get(api_url_for(server,
                                            "exchangebalancesresource"))
    assert_proper_response(response)
    json_data = response.json()
    assert json_data['message'] == ''
    result = json_data['result']
    assert_binance_balances_result(result['binance'])
    assert_poloniex_balances_result(result['poloniex'])