Updated tests to work with Telegram emojis

This commit is contained in:
Theagainmen 2020-06-05 19:08:54 +02:00 committed by GitHub
parent 04a2fb16aa
commit ff289a7177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1221,8 +1221,9 @@ def test_send_msg_buy_notification(default_conf, mocker) -> None:
'amount': 1333.3333333333335, 'amount': 1333.3333333333335,
'open_date': arrow.utcnow().shift(hours=-1) 'open_date': arrow.utcnow().shift(hours=-1)
}) })
'🔵'.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== '*Bittrex:* Buying ETH/BTC\n' \ == '\N{LARGE BLUE CIRCLE} *Bittrex:* Buying ETH/BTC\n' \
'*Amount:* `1333.33333333`\n' \ '*Amount:* `1333.33333333`\n' \
'*Open Rate:* `0.00001099`\n' \ '*Open Rate:* `0.00001099`\n' \
'*Current Rate:* `0.00001099`\n' \ '*Current Rate:* `0.00001099`\n' \
@ -1243,8 +1244,9 @@ def test_send_msg_buy_cancel_notification(default_conf, mocker) -> None:
'exchange': 'Bittrex', 'exchange': 'Bittrex',
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
}) })
''.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== ('*Bittrex:* Cancelling Open Buy Order for ETH/BTC') == ('\N{WARNING SIGN} *Bittrex:* Cancelling Open Buy Order for ETH/BTC')
def test_send_msg_sell_notification(default_conf, mocker) -> None: def test_send_msg_sell_notification(default_conf, mocker) -> None:
@ -1276,8 +1278,9 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None:
'open_date': arrow.utcnow().shift(hours=-1), 'open_date': arrow.utcnow().shift(hours=-1),
'close_date': arrow.utcnow(), 'close_date': arrow.utcnow(),
}) })
''.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== ('*Binance:* Selling KEY/ETH\n' == ('\N{WARNING SIGN} *Binance:* Selling KEY/ETH\n'
'*Amount:* `1333.33333333`\n' '*Amount:* `1333.33333333`\n'
'*Open Rate:* `0.00007500`\n' '*Open Rate:* `0.00007500`\n'
'*Current Rate:* `0.00003201`\n' '*Current Rate:* `0.00003201`\n'
@ -1305,7 +1308,7 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None:
'close_date': arrow.utcnow(), 'close_date': arrow.utcnow(),
}) })
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== ('*Binance:* Selling KEY/ETH\n' == ('\N{WARNING SIGN} *Binance:* Selling KEY/ETH\n'
'*Amount:* `1333.33333333`\n' '*Amount:* `1333.33333333`\n'
'*Open Rate:* `0.00007500`\n' '*Open Rate:* `0.00007500`\n'
'*Current Rate:* `0.00003201`\n' '*Current Rate:* `0.00003201`\n'
@ -1334,8 +1337,9 @@ def test_send_msg_sell_cancel_notification(default_conf, mocker) -> None:
'pair': 'KEY/ETH', 'pair': 'KEY/ETH',
'reason': 'Cancelled on exchange' 'reason': 'Cancelled on exchange'
}) })
''.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== ('*Binance:* Cancelling Open Sell Order for KEY/ETH. Reason: Cancelled on exchange') == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH. Reason: Cancelled on exchange')
msg_mock.reset_mock() msg_mock.reset_mock()
telegram.send_msg({ telegram.send_msg({
@ -1345,7 +1349,7 @@ def test_send_msg_sell_cancel_notification(default_conf, mocker) -> None:
'reason': 'timeout' 'reason': 'timeout'
}) })
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== ('*Binance:* Cancelling Open Sell Order for KEY/ETH. Reason: timeout') == ('\N{WARNING SIGN} *Binance:* Cancelling Open Sell Order for KEY/ETH. Reason: timeout')
# Reset singleton function to avoid random breaks # Reset singleton function to avoid random breaks
telegram._fiat_converter.convert_amount = old_convamount telegram._fiat_converter.convert_amount = old_convamount
@ -1379,7 +1383,8 @@ def test_warning_notification(default_conf, mocker) -> None:
'type': RPCMessageType.WARNING_NOTIFICATION, 'type': RPCMessageType.WARNING_NOTIFICATION,
'status': 'message' 'status': 'message'
}) })
assert msg_mock.call_args[0][0] == '*Warning:* `message`' ''.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] == '\N{WARNING SIGN} *Warning:* `message`'
def test_custom_notification(default_conf, mocker) -> None: def test_custom_notification(default_conf, mocker) -> None:
@ -1437,8 +1442,9 @@ def test_send_msg_buy_notification_no_fiat(default_conf, mocker) -> None:
'amount': 1333.3333333333335, 'amount': 1333.3333333333335,
'open_date': arrow.utcnow().shift(hours=-1) 'open_date': arrow.utcnow().shift(hours=-1)
}) })
'🔵'.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== '*Bittrex:* Buying ETH/BTC\n' \ == '\N{LARGE BLUE CIRCLE} *Bittrex:* Buying ETH/BTC\n' \
'*Amount:* `1333.33333333`\n' \ '*Amount:* `1333.33333333`\n' \
'*Open Rate:* `0.00001099`\n' \ '*Open Rate:* `0.00001099`\n' \
'*Current Rate:* `0.00001099`\n' \ '*Current Rate:* `0.00001099`\n' \
@ -1473,8 +1479,9 @@ def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None:
'open_date': arrow.utcnow().shift(hours=-2, minutes=-35, seconds=-3), 'open_date': arrow.utcnow().shift(hours=-2, minutes=-35, seconds=-3),
'close_date': arrow.utcnow(), 'close_date': arrow.utcnow(),
}) })
''.encode('ascii', 'namereplace')
assert msg_mock.call_args[0][0] \ assert msg_mock.call_args[0][0] \
== '*Binance:* Selling KEY/ETH\n' \ == '\N{WARNING SIGN} *Binance:* Selling KEY/ETH\n' \
'*Amount:* `1333.33333333`\n' \ '*Amount:* `1333.33333333`\n' \
'*Open Rate:* `0.00007500`\n' \ '*Open Rate:* `0.00007500`\n' \
'*Current Rate:* `0.00003201`\n' \ '*Current Rate:* `0.00003201`\n' \