Skip to content

Commit

Permalink
Add tests for /blacklist handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Mar 24, 2019
1 parent ffdca7e commit 8b2174d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
12 changes: 12 additions & 0 deletions freqtrade/tests/rpc/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,15 @@ def test_rpc_whitelist_dynamic(mocker, default_conf) -> None:
assert ret['method'] == 'VolumePairList'
assert ret['length'] == 4
assert ret['whitelist'] == default_conf['exchange']['pair_whitelist']


def test_rpc_blacklist(mocker, default_conf) -> None:
patch_coinmarketcap(mocker)
patch_exchange(mocker)
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())

freqtradebot = FreqtradeBot(default_conf)
rpc = RPC(freqtradebot)
ret = rpc._rpc_blacklist()
assert ret['method'] == 'StaticPairList'
assert ret['blacklist'] == default_conf['exchange']['pair_blacklist']
20 changes: 19 additions & 1 deletion freqtrade/tests/rpc/test_rpc_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_init(default_conf, mocker, caplog) -> None:
message_str = "rpc.telegram is listening for following commands: [['status'], ['profit'], " \
"['balance'], ['start'], ['stop'], ['forcesell'], ['forcebuy'], " \
"['performance'], ['daily'], ['count'], ['reload_conf'], " \
"['stopbuy'], ['whitelist'], ['help'], ['version']]"
"['stopbuy'], ['whitelist'], ['blacklist'], ['help'], ['version']]"

assert log_has(message_str, caplog.record_tuples)

Expand Down Expand Up @@ -1074,6 +1074,24 @@ def test_whitelist_dynamic(default_conf, update, mocker) -> None:
in msg_mock.call_args_list[0][0][0])


def test_blacklist_static(default_conf, update, mocker) -> None:
patch_coinmarketcap(mocker)
msg_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.rpc.telegram.Telegram',
_init=MagicMock(),
_send_msg=msg_mock
)
freqtradebot = get_patched_freqtradebot(mocker, default_conf)

telegram = Telegram(freqtradebot)

telegram._blacklist(bot=MagicMock(), update=update)
assert msg_mock.call_count == 1
assert ('Using blacklist `StaticPairList` with 2 pairs\n`DOGE/BTC, HOT/BTC`'
in msg_mock.call_args_list[0][0][0])


def test_help_handle(default_conf, update, mocker) -> None:
patch_coinmarketcap(mocker)
msg_mock = MagicMock()
Expand Down

0 comments on commit 8b2174d

Please sign in to comment.