From dfbc94c05b42d33900dc1d2353cd5f56614a5f2d Mon Sep 17 00:00:00 2001 From: Gerald Lonlas Date: Sat, 2 Jun 2018 15:12:02 -0700 Subject: [PATCH] Add missing test for CryptoToFiatConverter::convert_amount() --- freqtrade/tests/test_fiat_convert.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/freqtrade/tests/test_fiat_convert.py b/freqtrade/tests/test_fiat_convert.py index faf7462c0..60a39b953 100644 --- a/freqtrade/tests/test_fiat_convert.py +++ b/freqtrade/tests/test_fiat_convert.py @@ -161,7 +161,8 @@ def test_fiat_init_network_exception(mocker): fiat_convert._cryptomap = {} fiat_convert._load_cryptomap() - assert len(fiat_convert._cryptomap) == 0 + length_cryptomap = len(fiat_convert._cryptomap) + assert length_cryptomap == 0 def test_fiat_convert_without_network(): @@ -175,3 +176,22 @@ def test_fiat_convert_without_network(): assert fiat_convert._coinmarketcap is None assert fiat_convert._find_price(crypto_symbol='BTC', fiat_symbol='USD') == 0.0 CryptoToFiatConverter._coinmarketcap = cmc_temp + + +def test_convert_amount(mocker): + mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter.get_price', return_value=12345.0) + + fiat_convert = CryptoToFiatConverter() + result = fiat_convert.convert_amount( + crypto_amount=1.23, + crypto_symbol="BTC", + fiat_symbol="USD" + ) + assert result == 15184.35 + + result = fiat_convert.convert_amount( + crypto_amount=1.23, + crypto_symbol="BTC", + fiat_symbol="BTC" + ) + assert result == 1.23