Add more tests

This commit is contained in:
hroff-1902 2019-10-18 14:25:43 +03:00
parent e957894852
commit 5e731ec278

View File

@ -182,11 +182,13 @@ def test_list_markets(mocker, markets, capsys):
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 8 active markets:\n", assert ("Exchange Bittrex has 8 active markets: "
captured.out) "BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/USD, LTC/USDT, TKN/BTC, XLTCUSDT.\n"
in captured.out)
# # Test with --exchange # # Test with --exchange
# args = [ # args = [
@ -201,124 +203,200 @@ def test_list_markets(mocker, markets, capsys):
# Test with --all: all markets # Test with --all: all markets
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "--all" "list-markets", "--all",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 11 markets:\n", assert ("Exchange Bittrex has 11 markets: "
captured.out) "BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/USD, LTC/USDT, NEO/BTC, "
"TKN/BTC, XLTCUSDT, XRP/BTC.\n"
in captured.out)
# Test list-pairs subcommand: active pairs # Test list-pairs subcommand: active pairs
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-pairs", "list-pairs",
"--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 7 active pairs:\n", assert ("Exchange Bittrex has 7 active pairs: "
captured.out) "BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/USD, LTC/USDT, TKN/BTC.\n"
in captured.out)
# Test list-pairs subcommand with --all: all pairs # Test list-pairs subcommand with --all: all pairs
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-pairs", "--all" "list-pairs", "--all",
"--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 10 pairs:\n", assert ("Exchange Bittrex has 10 pairs: "
captured.out) "BLK/BTC, BTT/BTC, ETH/BTC, ETH/USDT, LTC/BTC, LTC/USD, LTC/USDT, NEO/BTC, "
"TKN/BTC, XRP/BTC.\n"
in captured.out)
# active markets, base=ETH, LTC # active markets, base=ETH, LTC
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--base", "ETH", "LTC" "--base", "ETH", "LTC",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 5 active markets with ETH, LTC as base currencies:\n", assert ("Exchange Bittrex has 5 active markets with ETH, LTC as base currencies: "
captured.out) "ETH/BTC, ETH/USDT, LTC/USD, LTC/USDT, XLTCUSDT.\n"
in captured.out)
# active markets, base=LTC # active markets, base=LTC
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--base", "LTC" "--base", "LTC",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 3 active markets with LTC as base currency:\n", assert ("Exchange Bittrex has 3 active markets with LTC as base currency: "
captured.out) "LTC/USD, LTC/USDT, XLTCUSDT.\n"
in captured.out)
# active markets, quote=USDT, USD # active markets, quote=USDT, USD
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--quote", "USDT", "USD" "--quote", "USDT", "USD",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 4 active markets with USDT, USD as quote currencies:\n", assert ("Exchange Bittrex has 4 active markets with USDT, USD as quote currencies: "
captured.out) "ETH/USDT, LTC/USD, LTC/USDT, XLTCUSDT.\n"
in captured.out)
# active markets, quote=USDT # active markets, quote=USDT
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--quote", "USDT" "--quote", "USDT",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 3 active markets with USDT as quote currency:\n", assert ("Exchange Bittrex has 3 active markets with USDT as quote currency: "
captured.out) "ETH/USDT, LTC/USDT, XLTCUSDT.\n"
in captured.out)
# active markets, base=LTC, quote=USDT # active markets, base=LTC, quote=USDT
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--base", "LTC", "--quote", "USDT" "--base", "LTC", "--quote", "USDT",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 2 active markets with LTC as base currency and " assert ("Exchange Bittrex has 2 active markets with LTC as base currency and "
"with USDT as quote currency:\n", "with USDT as quote currency: LTC/USDT, XLTCUSDT.\n"
captured.out) in captured.out)
# active pairs, base=LTC, quote=USDT # active pairs, base=LTC, quote=USDT
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-pairs", "list-pairs",
"--base", "LTC", "--quote", "USDT" "--base", "LTC", "--quote", "USDT",
"--print-list",
] ]
start_list_markets(get_args(args), True) start_list_markets(get_args(args), True)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 1 active pair with LTC as base currency and " assert ("Exchange Bittrex has 1 active pair with LTC as base currency and "
"with USDT as quote currency:\n", "with USDT as quote currency: LTC/USDT.\n"
captured.out) in captured.out)
# active markets, base=LTC, quote=USDT, NONEXISTENT # active markets, base=LTC, quote=USDT, NONEXISTENT
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--base", "LTC", "--quote", "USDT", "NONEXISTENT" "--base", "LTC", "--quote", "USDT", "NONEXISTENT",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 2 active markets with LTC as base currency and " assert ("Exchange Bittrex has 2 active markets with LTC as base currency and "
"with USDT, NONEXISTENT as quote currencies:\n", "with USDT, NONEXISTENT as quote currencies: LTC/USDT, XLTCUSDT.\n"
captured.out) in captured.out)
# active markets, base=LTC, quote=NONEXISTENT # active markets, base=LTC, quote=NONEXISTENT
args = [ args = [
'--config', 'config.json.example', '--config', 'config.json.example',
"list-markets", "list-markets",
"--base", "LTC", "--quote", "NONEXISTENT" "--base", "LTC", "--quote", "NONEXISTENT",
"--print-list",
] ]
start_list_markets(get_args(args), False) start_list_markets(get_args(args), False)
captured = capsys.readouterr() captured = capsys.readouterr()
assert re.match("Exchange Bittrex has 0 active markets with LTC as base currency and " assert ("Exchange Bittrex has 0 active markets with LTC as base currency and "
"with NONEXISTENT as quote currency.\n", "with NONEXISTENT as quote currency.\n"
captured.out) in captured.out)
# Test tabular output
args = [
'--config', 'config.json.example',
"list-markets",
]
start_list_markets(get_args(args), False)
captured = capsys.readouterr()
assert ("Exchange Bittrex has 8 active markets:\n"
in captured.out)
# Test tabular output, no markets found
args = [
'--config', 'config.json.example',
"list-markets",
"--base", "LTC", "--quote", "NONEXISTENT",
]
start_list_markets(get_args(args), False)
captured = capsys.readouterr()
assert ("Exchange Bittrex has 0 active markets with LTC as base currency and "
"with NONEXISTENT as quote currency.\n"
in captured.out)
# Test --print-json
args = [
'--config', 'config.json.example',
"list-markets",
"--print-json"
]
start_list_markets(get_args(args), False)
captured = capsys.readouterr()
assert ('["BLK/BTC","BTT/BTC","ETH/BTC","ETH/USDT","LTC/USD","LTC/USDT","TKN/BTC","XLTCUSDT"]'
in captured.out)
# Test --print-csv
args = [
'--config', 'config.json.example',
"list-markets",
"--print-csv"
]
start_list_markets(get_args(args), False)
captured = capsys.readouterr()
assert ("Id,Symbol,Base,Quote,Active,Is pair" in captured.out)
assert ("blkbtc,BLK/BTC,BLK,BTC,True,True" in captured.out)
assert ("BTTBTC,BTT/BTC,BTT,BTC,True,True" in captured.out)
# Test --one-column
args = [
'--config', 'config.json.example',
"list-markets",
"--one-column"
]
start_list_markets(get_args(args), False)
captured = capsys.readouterr()
assert re.search(r"^BLK/BTC$", captured.out, re.MULTILINE)
assert re.search(r"^BTT/BTC$", captured.out, re.MULTILINE)
def test_create_datadir_failed(caplog): def test_create_datadir_failed(caplog):