Update tests to use new file

This commit is contained in:
Matthias
2023-12-18 07:08:19 +01:00
parent b371593084
commit 651d2c06b9
2 changed files with 55 additions and 55 deletions
+53 -53
View File
@@ -32,7 +32,7 @@ from tests.conftest_trades import MOCK_TRADE_COUNT
def test_setup_utils_configuration(): def test_setup_utils_configuration():
args = [ args = [
'list-exchanges', '--config', 'config_examples/config_bittrex.example.json', 'list-exchanges', '--config', 'tests/testdata/testconfigs/main_test_config.json',
] ]
config = setup_utils_configuration(get_args(args), RunMode.OTHER) config = setup_utils_configuration(get_args(args), RunMode.OTHER)
@@ -49,7 +49,7 @@ def test_start_trading_fail(mocker, caplog):
exitmock = mocker.patch("freqtrade.worker.Worker.exit", MagicMock()) exitmock = mocker.patch("freqtrade.worker.Worker.exit", MagicMock())
args = [ args = [
'trade', 'trade',
'-c', 'config_examples/config_bittrex.example.json' '-c', 'tests/testdata/testconfigs/main_test_config.json'
] ]
start_trading(get_args(args)) start_trading(get_args(args))
assert exitmock.call_count == 1 assert exitmock.call_count == 1
@@ -68,7 +68,7 @@ def test_start_webserver(mocker, caplog):
args = [ args = [
'webserver', 'webserver',
'-c', 'config_examples/config_bittrex.example.json' '-c', 'tests/testdata/testconfigs/main_test_config.json'
] ]
start_webserver(get_args(args)) start_webserver(get_args(args))
assert api_server_mock.call_count == 1 assert api_server_mock.call_count == 1
@@ -84,7 +84,7 @@ def test_list_exchanges(capsys):
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match(r"Exchanges available for Freqtrade.*", captured.out) assert re.match(r"Exchanges available for Freqtrade.*", captured.out)
assert re.search(r".*binance.*", captured.out) assert re.search(r".*binance.*", captured.out)
assert re.search(r".*bittrex.*", captured.out) assert re.search(r".*bybit.*", captured.out)
# Test with --one-column # Test with --one-column
args = [ args = [
@@ -95,7 +95,7 @@ def test_list_exchanges(capsys):
start_list_exchanges(get_args(args)) start_list_exchanges(get_args(args))
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.search(r"^binance$", captured.out, re.MULTILINE) assert re.search(r"^binance$", captured.out, re.MULTILINE)
assert re.search(r"^bittrex$", captured.out, re.MULTILINE) assert re.search(r"^bybit$", captured.out, re.MULTILINE)
# Test with --all # Test with --all
args = [ args = [
@@ -107,7 +107,7 @@ def test_list_exchanges(capsys):
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match(r"All exchanges supported by the ccxt library.*", captured.out) assert re.match(r"All exchanges supported by the ccxt library.*", captured.out)
assert re.search(r".*binance.*", captured.out) assert re.search(r".*binance.*", captured.out)
assert re.search(r".*bittrex.*", captured.out) assert re.search(r".*bingx.*", captured.out)
assert re.search(r".*bitmex.*", captured.out) assert re.search(r".*bitmex.*", captured.out)
# Test with --one-column --all # Test with --one-column --all
@@ -120,7 +120,7 @@ def test_list_exchanges(capsys):
start_list_exchanges(get_args(args)) start_list_exchanges(get_args(args))
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.search(r"^binance$", captured.out, re.MULTILINE) assert re.search(r"^binance$", captured.out, re.MULTILINE)
assert re.search(r"^bittrex$", captured.out, re.MULTILINE) assert re.search(r"^bingx$", captured.out, re.MULTILINE)
assert re.search(r"^bitmex$", captured.out, re.MULTILINE) assert re.search(r"^bitmex$", captured.out, re.MULTILINE)
@@ -133,7 +133,7 @@ def test_list_timeframes(mocker, capsys):
'1h': 'hour', '1h': 'hour',
'1d': 'day', '1d': 'day',
} }
patch_exchange(mocker, api_mock=api_mock, id='bittrex') patch_exchange(mocker, api_mock=api_mock, id='bybit')
args = [ args = [
"list-timeframes", "list-timeframes",
] ]
@@ -143,25 +143,25 @@ def test_list_timeframes(mocker, capsys):
match=r"This command requires a configured exchange.*"): match=r"This command requires a configured exchange.*"):
start_list_timeframes(pargs) start_list_timeframes(pargs)
# Test with --config config_examples/config_bittrex.example.json # Test with --config tests/testdata/testconfigs/main_test_config.json
args = [ args = [
"list-timeframes", "list-timeframes",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
] ]
start_list_timeframes(get_args(args)) start_list_timeframes(get_args(args))
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Timeframes available for the exchange `Bittrex`: " assert re.match("Timeframes available for the exchange `Bybit`: "
"1m, 5m, 30m, 1h, 1d", "1m, 5m, 30m, 1h, 1d",
captured.out) captured.out)
# Test with --exchange bittrex # Test with --exchange bybit
args = [ args = [
"list-timeframes", "list-timeframes",
"--exchange", "bittrex", "--exchange", "bybit",
] ]
start_list_timeframes(get_args(args)) start_list_timeframes(get_args(args))
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Timeframes available for the exchange `Bittrex`: " assert re.match("Timeframes available for the exchange `Bybit`: "
"1m, 5m, 30m, 1h, 1d", "1m, 5m, 30m, 1h, 1d",
captured.out) captured.out)
@@ -190,7 +190,7 @@ def test_list_timeframes(mocker, capsys):
# Test with --one-column # Test with --one-column
args = [ args = [
"list-timeframes", "list-timeframes",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--one-column", "--one-column",
] ]
start_list_timeframes(get_args(args)) start_list_timeframes(get_args(args))
@@ -217,7 +217,7 @@ def test_list_timeframes(mocker, capsys):
def test_list_markets(mocker, markets_static, capsys): def test_list_markets(mocker, markets_static, capsys):
api_mock = MagicMock() api_mock = MagicMock()
patch_exchange(mocker, api_mock=api_mock, id='bittrex', mock_markets=markets_static) patch_exchange(mocker, api_mock=api_mock, id='binance', mock_markets=markets_static)
# Test with no --config # Test with no --config
args = [ args = [
@@ -229,15 +229,15 @@ def test_list_markets(mocker, markets_static, capsys):
match=r"This command requires a configured exchange.*"): match=r"This command requires a configured exchange.*"):
start_list_markets(pargs, False) start_list_markets(pargs, False)
# Test with --config config_examples/config_bittrex.example.json # Test with --config tests/testdata/testconfigs/main_test_config.json
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 12 active markets: " assert ("Exchange Binance has 12 active markets: "
"ADA/USDT:USDT, BLK/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, " "ADA/USDT:USDT, BLK/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, "
"LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n" "LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n"
in captured.out) in captured.out)
@@ -255,16 +255,16 @@ def test_list_markets(mocker, markets_static, capsys):
assert re.match("\nExchange Binance has 12 active markets:\n", assert re.match("\nExchange Binance has 12 active markets:\n",
captured.out) captured.out)
patch_exchange(mocker, api_mock=api_mock, id="bittrex", mock_markets=markets_static) patch_exchange(mocker, api_mock=api_mock, id="binance", mock_markets=markets_static)
# Test with --all: all markets # Test with --all: all markets
args = [ args = [
"list-markets", "--all", "list-markets", "--all",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 14 markets: " assert ("Exchange Binance has 14 markets: "
"ADA/USDT:USDT, BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, " "ADA/USDT:USDT, BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, ETH/USDT:USDT, "
"LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n" "LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, TKN/BTC, XLTCUSDT, XRP/BTC.\n"
in captured.out) in captured.out)
@@ -272,24 +272,24 @@ def test_list_markets(mocker, markets_static, capsys):
# Test list-pairs subcommand: active pairs # Test list-pairs subcommand: active pairs
args = [ args = [
"list-pairs", "list-pairs",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 9 active pairs: " assert ("Exchange Binance has 9 active pairs: "
"BLK/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XRP/BTC.\n" "BLK/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, NEO/BTC, TKN/BTC, XRP/BTC.\n"
in captured.out) in captured.out)
# Test list-pairs subcommand with --all: all pairs # Test list-pairs subcommand with --all: all pairs
args = [ args = [
"list-pairs", "--all", "list-pairs", "--all",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 11 pairs: " assert ("Exchange Binance has 11 pairs: "
"BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, " "BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/ETH, LTC/USD, LTC/USDT, NEO/BTC, "
"TKN/BTC, XRP/BTC.\n" "TKN/BTC, XRP/BTC.\n"
in captured.out) in captured.out)
@@ -297,133 +297,133 @@ def test_list_markets(mocker, markets_static, capsys):
# active markets, base=ETH, LTC # active markets, base=ETH, LTC
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "ETH", "LTC", "--base", "ETH", "LTC",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 7 active markets with ETH, LTC as base currencies: " assert ("Exchange Binance has 7 active markets with ETH, LTC as base currencies: "
"ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n" "ETH/BTC, ETH/USDT, ETH/USDT:USDT, LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, base=LTC # active markets, base=LTC
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--base", "LTC",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 4 active markets with LTC as base currency: " assert ("Exchange Binance has 4 active markets with LTC as base currency: "
"LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n" "LTC/BTC, LTC/ETH, LTC/USD, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, quote=USDT, USD # active markets, quote=USDT, USD
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--quote", "USDT", "USD", "--quote", "USDT", "USD",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 5 active markets with USDT, USD as quote currencies: " assert ("Exchange Binance has 5 active markets with USDT, USD as quote currencies: "
"ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, LTC/USD, XLTCUSDT.\n" "ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, LTC/USD, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, quote=USDT # active markets, quote=USDT
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--quote", "USDT", "--quote", "USDT",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 4 active markets with USDT as quote currency: " assert ("Exchange Binance has 4 active markets with USDT as quote currency: "
"ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, XLTCUSDT.\n" "ADA/USDT:USDT, ETH/USDT, ETH/USDT:USDT, XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, base=LTC, quote=USDT # active markets, base=LTC, quote=USDT
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--quote", "USDT", "--base", "LTC", "--quote", "USDT",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 1 active market with LTC as base currency and " assert ("Exchange Binance has 1 active market with LTC as base currency and "
"with USDT as quote currency: XLTCUSDT.\n" "with USDT as quote currency: XLTCUSDT.\n"
in captured.out) in captured.out)
# active pairs, base=LTC, quote=USDT # active pairs, base=LTC, quote=USDT
args = [ args = [
"list-pairs", "list-pairs",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--quote", "USD", "--base", "LTC", "--quote", "USD",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 1 active pair with LTC as base currency and " assert ("Exchange Binance has 1 active pair with LTC as base currency and "
"with USD as quote currency: LTC/USD.\n" "with USD as quote currency: LTC/USD.\n"
in captured.out) in captured.out)
# active markets, base=LTC, quote=USDT, NONEXISTENT # active markets, base=LTC, quote=USDT, NONEXISTENT
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--quote", "USDT", "NONEXISTENT", "--base", "LTC", "--quote", "USDT", "NONEXISTENT",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 1 active market with LTC as base currency and " assert ("Exchange Binance has 1 active market with LTC as base currency and "
"with USDT, NONEXISTENT as quote currencies: XLTCUSDT.\n" "with USDT, NONEXISTENT as quote currencies: XLTCUSDT.\n"
in captured.out) in captured.out)
# active markets, base=LTC, quote=NONEXISTENT # active markets, base=LTC, quote=NONEXISTENT
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--quote", "NONEXISTENT", "--base", "LTC", "--quote", "NONEXISTENT",
"--print-list", "--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 0 active markets with LTC as base currency and " assert ("Exchange Binance has 0 active markets with LTC as base currency and "
"with NONEXISTENT as quote currency.\n" "with NONEXISTENT as quote currency.\n"
in captured.out) in captured.out)
# Test tabular output # Test tabular output
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 12 active markets:\n" assert ("Exchange Binance has 12 active markets:\n"
in captured.out) in captured.out)
# Test tabular output, no markets found # Test tabular output, no markets found
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--base", "LTC", "--quote", "NONEXISTENT", "--base", "LTC", "--quote", "NONEXISTENT",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert ("Exchange Bittrex has 0 active markets with LTC as base currency and " assert ("Exchange Binance has 0 active markets with LTC as base currency and "
"with NONEXISTENT as quote currency.\n" "with NONEXISTENT as quote currency.\n"
in captured.out) in captured.out)
# Test --print-json # Test --print-json
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-json" "--print-json"
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
@@ -435,7 +435,7 @@ def test_list_markets(mocker, markets_static, capsys):
# Test --print-csv # Test --print-csv
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--print-csv" "--print-csv"
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
@@ -447,7 +447,7 @@ def test_list_markets(mocker, markets_static, capsys):
# Test --one-column # Test --one-column
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--one-column" "--one-column"
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
@@ -459,7 +459,7 @@ def test_list_markets(mocker, markets_static, capsys):
# Test --one-column # Test --one-column
args = [ args = [
"list-markets", "list-markets",
'--config', 'config_examples/config_bittrex.example.json', '--config', 'tests/testdata/testconfigs/main_test_config.json',
"--one-column" "--one-column"
] ]
with pytest.raises(OperationalException, match=r"Cannot get markets.*"): with pytest.raises(OperationalException, match=r"Cannot get markets.*"):
@@ -971,7 +971,7 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
patched_configuration_load_config_file(mocker, default_conf) patched_configuration_load_config_file(mocker, default_conf)
args = [ args = [
'test-pairlist', 'test-pairlist',
'-c', 'config_examples/config_bittrex.example.json' '-c', 'tests/testdata/testconfigs/main_test_config.json'
] ]
start_test_pairlist(get_args(args)) start_test_pairlist(get_args(args))
@@ -985,7 +985,7 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
args = [ args = [
'test-pairlist', 'test-pairlist',
'-c', 'config_examples/config_bittrex.example.json', '-c', 'tests/testdata/testconfigs/main_test_config.json',
'--one-column', '--one-column',
] ]
start_test_pairlist(get_args(args)) start_test_pairlist(get_args(args))
@@ -994,7 +994,7 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
args = [ args = [
'test-pairlist', 'test-pairlist',
'-c', 'config_examples/config_bittrex.example.json', '-c', 'tests/testdata/testconfigs/main_test_config.json',
'--print-json', '--print-json',
] ]
start_test_pairlist(get_args(args)) start_test_pairlist(get_args(args))
+2 -2
View File
@@ -377,7 +377,7 @@ def test_start_plot_dataframe(mocker):
aup = mocker.patch("freqtrade.plot.plotting.load_and_plot_trades", MagicMock()) aup = mocker.patch("freqtrade.plot.plotting.load_and_plot_trades", MagicMock())
args = [ args = [
"plot-dataframe", "plot-dataframe",
"--config", "config_examples/config_bittrex.example.json", "--config", "tests/testdata/testconfigs/main_test_config.json",
"--pairs", "ETH/BTC" "--pairs", "ETH/BTC"
] ]
start_plot_dataframe(get_args(args)) start_plot_dataframe(get_args(args))
@@ -420,7 +420,7 @@ def test_start_plot_profit(mocker):
aup = mocker.patch("freqtrade.plot.plotting.plot_profit", MagicMock()) aup = mocker.patch("freqtrade.plot.plotting.plot_profit", MagicMock())
args = [ args = [
"plot-profit", "plot-profit",
"--config", "config_examples/config_bittrex.example.json", "--config", "tests/testdata/testconfigs/main_test_config.json",
"--pairs", "ETH/BTC" "--pairs", "ETH/BTC"
] ]
start_plot_profit(get_args(args)) start_plot_profit(get_args(args))