Exemplo n.º 1
0
def test_query_latest_asset_value_distribution(rotkehlchen_server):
    """Test that query_latest_asset_value_distribution API call works as expected"""
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_latest_asset_value_distribution()
    assert response['message'] == ''
    distribution = response['result']
    assert isinstance(distribution[0]['asset'], str)
    assert distribution[0] == {
        'time': 1488326400,
        'asset': 'BTC',
        'amount': '1',
        'usd_value': '1222.66',
    }
    assert isinstance(distribution[1]['asset'], str)
    assert distribution[1] == {
        'time': 1488326400,
        'asset': 'ETH',
        'amount': '10',
        'usd_value': '4517.4',
    }
    assert isinstance(distribution[2]['asset'], str)
    assert distribution[2] == {
        'time': 1488326400,
        'asset': 'EUR',
        'amount': '100',
        'usd_value': '119',
    }
    assert isinstance(distribution[3]['asset'], str)
    assert distribution[3] == {
        'time': 1488326400,
        'asset': 'XMR',
        'amount': '5',
        'usd_value': '61.5',
    }
Exemplo n.º 2
0
def test_query_latest_location_value_distribution(rotkehlchen_server):
    """Test that query_latest_location_value_distribution API call works as expected"""
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_latest_location_value_distribution()
    assert response['message'] == ''
    distribution = response['result']
    assert all(entry['time'] == Timestamp(1491607800)
               for entry in distribution)
    assert len(distribution) == 5

    assert find_dict_in_list(distribution, {
        'location': 'banks',
        'usd_value': '10000'
    })
    assert find_dict_in_list(distribution, {
        'location': 'blockchain',
        'usd_value': '200000'
    })
    assert find_dict_in_list(distribution, {
        'location': 'kraken',
        'usd_value': '2000'
    })
    assert find_dict_in_list(distribution, {
        'location': 'poloniex',
        'usd_value': '100'
    })
    assert find_dict_in_list(distribution, {
        'location': 'total',
        'usd_value': '10700.5'
    })
Exemplo n.º 3
0
def test_get_netvalue_data_from_date(data_dir, username):
    msg_aggregator = MessagesAggregator()
    data = DataHandler(data_dir, msg_aggregator)
    data.unlock(username, '123', create_new=True)
    add_starting_balances(data)

    times, values = data.db.get_netvalue_data(Timestamp(1491607800))
    assert len(times) == 1
    assert times[0] == 1491607800
    assert len(values) == 1
    assert values[0] == '10700.5'
Exemplo n.º 4
0
def test_query_timed_balances_data(rotkehlchen_server):
    """Test that query_timed_balances_data API call works as expected and that
    it properly serializes assets but also ignores unknown ones
    """
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_timed_balances_data('BTC', 0, 99999999999)
    assert response['message'] == ''
    assert len(response['result']) == 1
    assert response['result'][0] == {'time': 1488326400, 'amount': '1', 'usd_value': '1222.66'}

    response = rotkehlchen_server.query_timed_balances_data('DSXXADA', 0, 99999999999)
    assert not response['result']
    assert response['message'] == 'Unknown asset DSXXADA provided.'
Exemplo n.º 5
0
def test_query_netvalue_data(rotkehlchen_server):
    """Test that query_netvalue_data API call works as expected"""
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_netvalue_data()
    times = response['times']
    values = response['data']
    assert len(times) == 3
    assert times[0] == 1451606400
    assert times[1] == 1461606500
    assert times[2] == 1491607800
    assert len(values) == 3
    assert values[0] == '1500'
    assert values[1] == '4500'
    assert values[2] == '10700.5'
Exemplo n.º 6
0
def test_get_netvalue_data(data_dir, username):
    msg_aggregator = MessagesAggregator()
    data = DataHandler(data_dir, msg_aggregator)
    data.unlock(username, '123', create_new=True)
    add_starting_balances(data)

    times, values = data.db.get_netvalue_data()
    assert len(times) == 3
    assert times[0] == 1451606400
    assert times[1] == 1461606500
    assert times[2] == 1491607800
    assert len(values) == 3
    assert values[0] == '1500'
    assert values[1] == '4500'
    assert values[2] == '10700.5'
Exemplo n.º 7
0
def test_query_owned_assets(rotkehlchen_server):
    """Test that query_owned_assets API call works as expected and that
    it properly serializes assets but also ignores unknown ones
    """
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_owned_assets()
    assert response['message'] == ''
    assert response['result'] == ['BTC', 'ETH', 'EUR', 'XMR']

    # Check that we can get the warning for the unknown asset via the api
    response = rotkehlchen_server.consume_messages()
    assert response['message'] == ''
    assert response['result']['errors'] == []
    warnings = response['result']['warnings']
    assert len(warnings) == 1
    assert 'Unknown/unsupported asset ADSADX found in the database' in warnings[0]
Exemplo n.º 8
0
def test_query_latest_location_value_distribution(rotkehlchen_server):
    """Test that query_latest_location_value_distribution API call works as expected"""
    add_starting_balances(rotkehlchen_server.rotkehlchen.data)

    response = rotkehlchen_server.query_latest_location_value_distribution()
    assert response['message'] == ''
    distribution = response['result']
    assert all(entry['time'] == Timestamp(1491607800) for entry in distribution)
    assert distribution[0]['location'] == 'banks'
    assert distribution[0]['usd_value'] == '10000'
    assert distribution[1]['location'] == 'blockchain'
    assert distribution[1]['usd_value'] == '200000'
    assert distribution[2]['location'] == 'kraken'
    assert distribution[2]['usd_value'] == '2000'
    assert distribution[3]['location'] == 'poloniex'
    assert distribution[3]['usd_value'] == '100'
    assert distribution[4]['location'] == 'total'
    assert distribution[4]['usd_value'] == '10700.5'
Exemplo n.º 9
0
def test_get_latest_location_value_distribution(data_dir, username):
    msg_aggregator = MessagesAggregator()
    data = DataHandler(data_dir, msg_aggregator)
    data.unlock(username, '123', create_new=True)

    add_starting_balances(data)
    distribution = data.db.get_latest_location_value_distribution()
    assert len(distribution) == 5
    assert all(entry.time == Timestamp(1491607800) for entry in distribution)
    assert distribution[0].location == 'banks'
    assert distribution[0].usd_value == '10000'
    assert distribution[1].location == 'blockchain'
    assert distribution[1].usd_value == '200000'
    assert distribution[2].location == 'kraken'
    assert distribution[2].usd_value == '2000'
    assert distribution[3].location == 'poloniex'
    assert distribution[3].usd_value == '100'
    assert distribution[4].location == 'total'
    assert distribution[4].usd_value == '10700.5'
Exemplo n.º 10
0
def test_get_latest_asset_value_distribution(data_dir, username):
    msg_aggregator = MessagesAggregator()
    data = DataHandler(data_dir, msg_aggregator)
    data.unlock(username, '123', create_new=True)

    balances = add_starting_balances(data)

    assets = data.db.get_latest_asset_value_distribution()
    assert len(assets) == 4
    assert assets[0] == balances[0]
    assert assets[1] == balances[1]
    assert assets[2] == balances[2]
    assert assets[3] == balances[3]