Adjust tests
This commit is contained in:
@@ -41,7 +41,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
||||
with pytest.raises(RPCException, match=r'.*no active trade*'):
|
||||
rpc._rpc_trade_status()
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
results = rpc._rpc_trade_status()
|
||||
assert {
|
||||
'trade_id': 1,
|
||||
@@ -116,7 +116,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||
with pytest.raises(RPCException, match=r'.*no active order*'):
|
||||
rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
result, headers = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
assert "Since" in headers
|
||||
@@ -162,7 +162,7 @@ def test_rpc_daily_profit(default_conf, update, ticker, fee,
|
||||
rpc = RPC(freqtradebot)
|
||||
rpc._fiat_converter = CryptoToFiatConverter()
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
assert trade
|
||||
|
||||
@@ -217,7 +217,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
rpc._rpc_trade_statistics(stake_currency, fiat_display_currency)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
# Simulate fulfilled LIMIT_BUY order for trade
|
||||
trade.update(limit_buy_order)
|
||||
@@ -231,7 +231,7 @@ def test_rpc_trade_statistics(default_conf, ticker, ticker_sell_up, fee,
|
||||
trade.close_date = datetime.utcnow()
|
||||
trade.is_open = False
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
# Simulate fulfilled LIMIT_BUY order for trade
|
||||
trade.update(limit_buy_order)
|
||||
@@ -299,7 +299,7 @@ def test_rpc_trade_statistics_closed(mocker, default_conf, ticker, fee,
|
||||
rpc = RPC(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
# Simulate fulfilled LIMIT_BUY order for trade
|
||||
trade.update(limit_buy_order)
|
||||
@@ -529,7 +529,7 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
||||
msg = rpc._rpc_forcesell('all')
|
||||
assert msg == {'result': 'Created sell orders for all open trades.'}
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
msg = rpc._rpc_forcesell('all')
|
||||
assert msg == {'result': 'Created sell orders for all open trades.'}
|
||||
|
||||
@@ -563,7 +563,7 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
||||
assert cancel_order_mock.call_count == 1
|
||||
assert trade.amount == filled_amount
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.filter(Trade.id == '2').first()
|
||||
amount = trade.amount
|
||||
# make an limit-buy open trade, if there is no 'filled', don't sell it
|
||||
@@ -582,7 +582,7 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
||||
assert cancel_order_mock.call_count == 2
|
||||
assert trade.amount == amount
|
||||
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
# make an limit-sell open trade
|
||||
mocker.patch(
|
||||
'freqtrade.exchange.Exchange.get_order',
|
||||
@@ -613,7 +613,7 @@ def test_performance_handle(default_conf, ticker, limit_buy_order, fee,
|
||||
rpc = RPC(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
assert trade
|
||||
|
||||
@@ -649,7 +649,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None:
|
||||
assert counts["current"] == 0
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
counts = rpc._rpc_count()
|
||||
assert counts["current"] == 1
|
||||
|
||||
|
@@ -267,7 +267,7 @@ def test_api_count(botclient, mocker, ticker, fee, markets):
|
||||
assert rc.json["max"] == 1.0
|
||||
|
||||
# Create some test data
|
||||
ftbot.create_trades()
|
||||
ftbot.process_maybe_execute_buys()
|
||||
rc = client_get(client, f"{BASE_URI}/count")
|
||||
assert_response(rc)
|
||||
assert rc.json["current"] == 1.0
|
||||
@@ -333,7 +333,7 @@ def test_api_profit(botclient, mocker, ticker, fee, markets, limit_buy_order, li
|
||||
assert len(rc.json) == 1
|
||||
assert rc.json == {"error": "Error querying _profit: no closed trade"}
|
||||
|
||||
ftbot.create_trades()
|
||||
ftbot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
|
||||
# Simulate fulfilled LIMIT_BUY order for trade
|
||||
@@ -422,7 +422,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
|
||||
assert_response(rc, 200)
|
||||
assert rc.json == []
|
||||
|
||||
ftbot.create_trades()
|
||||
ftbot.process_maybe_execute_buys()
|
||||
rc = client_get(client, f"{BASE_URI}/status")
|
||||
assert_response(rc)
|
||||
assert len(rc.json) == 1
|
||||
@@ -552,7 +552,7 @@ def test_api_forcesell(botclient, mocker, ticker, fee, markets):
|
||||
assert_response(rc, 502)
|
||||
assert rc.json == {"error": "Error querying _forcesell: invalid argument"}
|
||||
|
||||
ftbot.create_trades()
|
||||
ftbot.process_maybe_execute_buys()
|
||||
|
||||
rc = client_post(client, f"{BASE_URI}/forcesell",
|
||||
data='{"tradeid": "1"}')
|
||||
|
@@ -189,7 +189,7 @@ def test_status(default_conf, update, mocker, fee, ticker,) -> None:
|
||||
|
||||
# Create some test data
|
||||
for _ in range(3):
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
telegram._status(update=update, context=MagicMock())
|
||||
assert msg_mock.call_count == 1
|
||||
@@ -236,7 +236,7 @@ def test_status_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
msg_mock.reset_mock()
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
# Trigger status while we have a fulfilled order for the open trade
|
||||
telegram._status(update=update, context=MagicMock())
|
||||
|
||||
@@ -285,7 +285,7 @@ def test_status_table_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
msg_mock.reset_mock()
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
telegram._status_table(update=update, context=MagicMock())
|
||||
|
||||
@@ -322,7 +322,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, fee,
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
assert trade
|
||||
|
||||
@@ -352,7 +352,7 @@ def test_daily_handle(default_conf, update, ticker, limit_buy_order, fee,
|
||||
msg_mock.reset_mock()
|
||||
freqtradebot.config['max_open_trades'] = 2
|
||||
# Add two other trades
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
trades = Trade.query.all()
|
||||
for trade in trades:
|
||||
@@ -431,7 +431,7 @@ def test_profit_handle(default_conf, update, ticker, ticker_sell_up, fee,
|
||||
msg_mock.reset_mock()
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
|
||||
# Simulate fulfilled LIMIT_BUY order for trade
|
||||
@@ -709,7 +709,7 @@ def test_forcesell_handle(default_conf, update, ticker, fee,
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
trade = Trade.query.first()
|
||||
assert trade
|
||||
@@ -764,7 +764,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, fee,
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
|
||||
# Decrease the price and sell it
|
||||
mocker.patch.multiple(
|
||||
@@ -821,7 +821,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, fee, mocker) -> None
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
rpc_mock.reset_mock()
|
||||
|
||||
# /forcesell all
|
||||
@@ -971,7 +971,7 @@ def test_performance_handle(default_conf, update, ticker, fee,
|
||||
telegram = Telegram(freqtradebot)
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
trade = Trade.query.first()
|
||||
assert trade
|
||||
|
||||
@@ -1014,7 +1014,7 @@ def test_count_handle(default_conf, update, ticker, fee, mocker) -> None:
|
||||
freqtradebot.state = State.RUNNING
|
||||
|
||||
# Create some test data
|
||||
freqtradebot.create_trades()
|
||||
freqtradebot.process_maybe_execute_buys()
|
||||
msg_mock.reset_mock()
|
||||
telegram._count(update=update, context=MagicMock())
|
||||
|
||||
|
Reference in New Issue
Block a user