def test_context_load_trade_counter_error() -> None: settings = Setting() settings.TRADE_COUNTER = MagicMock() # type:ignore context = Context(settings) context.load_statistic() with pytest.raises(SettingError): context.load_trade_counter()
def test_context_custom_setting() -> None: with patch("monkq.exchange.bitmex.exchange.BitmexDataloader"): settings = Setting() settings.STRATEGY = TestStrategy # type:ignore settings.TRADE_COUNTER = TestTradeCounter # type:ignore settings.STATISTIC = TestStatistic # type:ignore settings.ACCOUNTS[0]['ACCOUNT_MODEL'] = TestAccount # type:ignore settings.EXCHANGES['bitmex']['ENGINE'] = TestExchange # type:ignore context = Context(settings) context.setup_context() assert isinstance(context.strategy, TestStrategy) assert isinstance(context.trade_counter, TestTradeCounter) assert isinstance(context.stat, TestStatistic) assert isinstance(context.accounts, dict) assert isinstance(context.exchanges, dict)