def test_get_account_balances(requests_mock, ig): ig_request_account_details(requests_mock) balance, deposit = ig.get_account_balances() assert balance is not None assert deposit is not None assert balance == 16093.12 assert deposit == 10000.0
def mock_http_calls(requests_mock): ig_request_login(requests_mock) ig_request_set_account(requests_mock) ig_request_account_details(requests_mock) ig_request_open_positions(requests_mock) ig_request_market_info(requests_mock) ig_request_search_market(requests_mock) ig_request_prices(requests_mock) ig_request_trade(requests_mock) ig_request_confirm_trade(requests_mock) ig_request_navigate_market(requests_mock) ig_request_navigate_market(requests_mock, args="668394", data="mock_navigate_markets_markets.json") ig_request_navigate_market(requests_mock, args="77976799", data="mock_navigate_markets_markets.json") ig_request_navigate_market(requests_mock, args="89291253", data="mock_navigate_markets_markets.json") ig_request_watchlist(requests_mock) ig_request_watchlist(requests_mock, args="12345678", data="mock_watchlist.json") av_request_prices(requests_mock) av_request_macd_ext(requests_mock)
def test_get_account_balances_fail(requests_mock, ig): ig_request_account_details(requests_mock, fail=True) with pytest.raises(RuntimeError) as e: balance, deposit = ig.get_account_balances()
def test_get_account_used_perc_fail(ig, requests_mock): ig_request_account_details(requests_mock, fail=True) with pytest.raises(RuntimeError) as e: perc = ig.get_account_used_perc()
def test_get_account_used_perc(ig, requests_mock): ig_request_account_details(requests_mock) perc = ig.get_account_used_perc() assert perc is not None assert perc == 62.138354775208285
def test_get_account_used_perc_fail(ig, requests_mock): ig_request_account_details(requests_mock, fail=True) perc = ig.get_account_used_perc() assert perc is None
def test_get_account_balances_fail(requests_mock, ig): ig_request_account_details(requests_mock, fail=True) balance, deposit = ig.get_account_balances() assert balance is None assert deposit is None