merged upstream
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, PropertyMock
|
||||
@@ -14,11 +15,14 @@ from freqtrade.commands import (start_backtesting_show, start_convert_data, star
|
||||
start_list_exchanges, start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_strategy, start_show_trades,
|
||||
start_test_pairlist, start_trading, start_webserver)
|
||||
from freqtrade.commands.db_commands import start_convert_db
|
||||
from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui,
|
||||
get_ui_download_url, read_ui_version)
|
||||
from freqtrade.configuration import setup_utils_configuration
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.persistence.models import init_db
|
||||
from freqtrade.persistence.pairlock_middleware import PairLocks
|
||||
from tests.conftest import (CURRENT_TEST_STRATEGY, create_mock_trades, get_args, log_has,
|
||||
log_has_re, patch_exchange, patched_configuration_load_config_file)
|
||||
from tests.conftest_trades import MOCK_TRADE_COUNT
|
||||
@@ -1458,3 +1462,33 @@ def test_backtesting_show(mocker, testdatadir, capsys):
|
||||
assert sbr.call_count == 1
|
||||
out, err = capsys.readouterr()
|
||||
assert "Pairs for Strategy" in out
|
||||
|
||||
|
||||
def test_start_convert_db(mocker, fee, tmpdir, caplog):
|
||||
db_src_file = Path(f"{tmpdir}/db.sqlite")
|
||||
db_from = f"sqlite:///{db_src_file}"
|
||||
db_target_file = Path(f"{tmpdir}/db_target.sqlite")
|
||||
db_to = f"sqlite:///{db_target_file}"
|
||||
args = [
|
||||
"convert-db",
|
||||
"--db-url-from",
|
||||
db_from,
|
||||
"--db-url",
|
||||
db_to,
|
||||
]
|
||||
|
||||
assert not db_src_file.is_file()
|
||||
init_db(db_from, False)
|
||||
|
||||
create_mock_trades(fee)
|
||||
|
||||
PairLocks.timeframe = '5m'
|
||||
PairLocks.lock_pair('XRP/USDT', datetime.now(), 'Random reason 125', side='long')
|
||||
assert db_src_file.is_file()
|
||||
assert not db_target_file.is_file()
|
||||
|
||||
pargs = get_args(args)
|
||||
pargs['config'] = None
|
||||
start_convert_db(pargs)
|
||||
|
||||
assert db_target_file.is_file()
|
||||
|
||||
@@ -235,9 +235,20 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||
freqtradebot.state = State.RUNNING
|
||||
with pytest.raises(RPCException, match=r'.*no active trade*'):
|
||||
rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange._is_dry_limit_order_filled', return_value=False)
|
||||
freqtradebot.enter_positions()
|
||||
|
||||
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
assert "Since" in headers
|
||||
assert "Pair" in headers
|
||||
assert 'instantly' == result[0][2]
|
||||
assert 'ETH/BTC' in result[0][1]
|
||||
assert '0.00' == result[0][3]
|
||||
assert isnan(fiat_profit_sum)
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange._is_dry_limit_order_filled', return_value=True)
|
||||
freqtradebot.process()
|
||||
|
||||
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
assert "Since" in headers
|
||||
assert "Pair" in headers
|
||||
@@ -245,8 +256,8 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||
assert 'ETH/BTC' in result[0][1]
|
||||
assert '-0.41%' == result[0][3]
|
||||
assert isnan(fiat_profit_sum)
|
||||
# Test with fiatconvert
|
||||
|
||||
# Test with fiatconvert
|
||||
rpc._fiat_converter = CryptoToFiatConverter()
|
||||
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||
assert "Since" in headers
|
||||
|
||||
@@ -1416,14 +1416,14 @@ def test_migrate_set_sequence_ids():
|
||||
engine = MagicMock()
|
||||
engine.begin = MagicMock()
|
||||
engine.name = 'postgresql'
|
||||
set_sequence_ids(engine, 22, 55)
|
||||
set_sequence_ids(engine, 22, 55, 5)
|
||||
|
||||
assert engine.begin.call_count == 1
|
||||
engine.reset_mock()
|
||||
engine.begin.reset_mock()
|
||||
|
||||
engine.name = 'somethingelse'
|
||||
set_sequence_ids(engine, 22, 55)
|
||||
set_sequence_ids(engine, 22, 55, 6)
|
||||
|
||||
assert engine.begin.call_count == 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user