def test_underlying_requests(empty_data_folder):
    """This test might fail on MacOS
    see #1512
    """
    specter_mock = Specter(data_folder=empty_data_folder)
    requests_session = specter_mock.requests_session()
    currency = "eur"
    price = requests_session.get(
        "https://www.bitstamp.net/api/v2/ticker/btc{}".format(currency)
    ).json()["last"]
    assert type(price) == str
    assert float(price)
def test_failsafe_request_get(empty_data_folder):
    specter_mock = Specter(data_folder=empty_data_folder)
    requests_session = specter_mock.requests_session()
    currency = "notExisting"
    url = "https://www.bitstamp.net/api/v2/ticker/btc{}".format(currency)
    with pytest.raises(SpecterError) as se:
        failsafe_request_get(requests_session, url)
    assert f"The currency_pair does not seem to exist for that provider" in str(
        se.value
    )

    currency = "usd"
    # timestamp most probably in the future
    url = "https://www.bitstamp.net/api/v2/ohlc/btc{}/?limit=A&step=86400&start={}".format(
        currency, 6275453759
    )
    with pytest.raises(SpecterError) as se:
        failsafe_request_get(requests_session, url)
    assert str(se.value).startswith("JSON error:")