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 requests(requests_mock): ig_request_login(requests_mock) ig_request_set_account(requests_mock) ig_request_market_info(requests_mock) ig_request_search_market(requests_mock) ig_request_watchlist(requests_mock, data="mock_watchlist_list.json") ig_request_watchlist(requests_mock, args="12345678", data="mock_watchlist.json")
def broker(requests_mock, config): ig_request_login(requests_mock) ig_request_set_account(requests_mock) ig_request_market_info(requests_mock) ig_request_search_market(requests_mock) ig_request_watchlist(requests_mock, data="mock_watchlist_list.json") ig_request_watchlist(requests_mock, args="12345678", data="mock_watchlist.json") return Broker(BrokerFactory(config))
def test_search_market(ig, requests_mock): ig_request_market_info(requests_mock) ig_request_search_market(requests_mock) markets = ig.search_market("mock") assert markets is not None assert isinstance(markets, list) assert len(markets) == 8 assert isinstance(markets[0], Market)
def test_search_market(ig, requests_mock): ig_request_search_market(requests_mock) markets = ig.search_market("mock") assert markets is not None assert len(markets) == 8 assert "epic" in markets[0] assert "expiry" in markets[0] assert "bid" in markets[0] assert "offer" in markets[0]
def test_search_market(config, make_broker, requests_mock): """ Test the MarketProvider search_market() function """ # Define configuration for this test config["general"]["market_source"]["value"] = "list" config["general"]["epic_ids_filepath"] = "test/test_data/epics_list.txt" mp = MarketProvider(config, make_broker) # The mock search data contains multiple markets ig_request_search_market(requests_mock, data="mock_error.json") with pytest.raises(RuntimeError): market = mp.search_market("mock")
def test_search_market_fail(ig, requests_mock): ig_request_search_market(requests_mock, fail=True) with pytest.raises(RuntimeError) as e: markets = ig.search_market("mock")
def test_search_market_fail(ig, requests_mock): ig_request_search_market(requests_mock, fail=True) markets = ig.search_market("mock") assert markets is None