Esempio n. 1
0
def test_cryptocompare_historical_data_use_cached_price(data_dir, database, historical_price_test_data):  # pylint: disable=unused-argument  # noqa: E501
    """Test that the cryptocompare cache is used"""
    cc = Cryptocompare(data_directory=data_dir, database=database)
    with patch.object(cc, 'query_endpoint_histohour') as histohour_mock:
        result = cc.query_historical_price(
            from_asset=A_ETH,
            to_asset=A_EUR,
            timestamp=1511627623,
        )
        # make sure that histohour was not called, in essence that the cache was used
        assert histohour_mock.call_count == 0

    assert result == FVal(396.56)
Esempio n. 2
0
def test_cryptocompare_histohour_query_old_ts_xcp(
        accounting_data_dir,
        price_historian,  # pylint: disable=unused-argument
):
    """Test that as a result of this query a crash does not happen.

    Regression for: https://github.com/rotkehlchenio/rotkehlchen/issues/432
    Unfortunately still no price is found so we have to expect a NoPriceForGivenTimestamp

    This test is now skipped since it's a subset of:
    test_end_to_end_tax_report::test_unknown_cryptocompare_asset_and_price_not_found_in_history

    When more price data sources are introduced then this should probably be unskipped
    to focus on the cryptocompare case. But at the moment both tests follow the same
    path and are probably slow due to the price querying.
    """
    with pytest.raises(NoPriceForGivenTimestamp):
        cc = Cryptocompare(data_directory=accounting_data_dir)
        cc.query_historical_price(
            from_asset=Asset('XCP'),
            to_asset=A_USD,
            timestamp=1392685761,
            historical_data_start=1438387200,
        )