def test_kwargs(self, mock_trade_close): tick = TickFactory() trade = TradeFactory() trade.close_from_tick(tick, test_arg="test_value") assert mock_trade_close.call_count == 1 assert mock_trade_close.call_args_list[0][1][ "test_arg"] == "test_value"
def test_close_value(self, mock_trade_close): tick = TickFactory() trade = TradeFactory() trade.current_close_value = 87.9 trade.close_from_tick(tick) assert mock_trade_close.call_count == 1 assert mock_trade_close.call_args_list[0][1]["close_value"] == 87.9
def test_datetime(self, mock_trade_close): dt = arrow.get("2020-01-01 12:34:56") tick = TickFactory(datetime=dt) trade = TradeFactory() trade.close_from_tick(tick) assert mock_trade_close.call_count == 1 assert mock_trade_close.call_args_list[0][1]["datetime"] == dt
def test_response(self, mocker): mocker.patch(f"{CLASS_TRADE_DEFINITION_PATH}.close", return_value="test_close") tick = TickFactory() trade = TradeFactory() response = trade.close_from_tick(tick) assert response == "test_close"
def test_call_update_from_tick(self, mock_update_from_tick): tick = TickFactory() trade = TradeFactory() trade.close_from_tick(tick) assert mock_update_from_tick.call_args_list == [call(tick)]