def test_fiat_init_network_exception(mocker): # Because CryptoToFiatConverter is a Singleton we reset the listings listmock = MagicMock(side_effect=RequestException) mocker.patch.multiple( 'freqtrade.fiat_convert.Market', listings=listmock, ) # with pytest.raises(RequestEsxception): fiat_convert = CryptoToFiatConverter() fiat_convert._cryptomap = {} fiat_convert._load_cryptomap() length_cryptomap = len(fiat_convert._cryptomap) assert length_cryptomap == 0
def test_fiat_invalid_response(mocker, caplog): # Because CryptoToFiatConverter is a Singleton we reset the listings listmock = MagicMock(return_value="{'novalidjson':DEADBEEFf}") mocker.patch.multiple( 'freqtrade.fiat_convert.Market', listings=listmock, ) # with pytest.raises(RequestEsxception): fiat_convert = CryptoToFiatConverter() fiat_convert._cryptomap = {} fiat_convert._load_cryptomap() length_cryptomap = len(fiat_convert._cryptomap) assert length_cryptomap == 0 assert log_has( 'Could not load FIAT Cryptocurrency map for the following problem: TypeError', caplog.record_tuples)