From 65127533efc07d3ce277646356dc24765428c375 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste LE STANG Date: Sun, 7 Jan 2018 21:24:17 +0100 Subject: [PATCH] fixing unittest --- freqtrade/tests/exchange/test_exchange.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index e47bb56eb..e7914466e 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -162,24 +162,27 @@ def test_get_balances_prod(default_conf, mocker): def test_get_ticker(mocker, ticker): api_mock = MagicMock() - api_mock.get_ticker = MagicMock(return_value=ticker()) - mocker.patch('freqtrade.exchange._API', api_mock) + tick = {"success": True, 'result': {'Bid': 0.00001098, 'Ask': 0.00001099, 'Last': 0.0001}} + api_mock.get_ticker = MagicMock(return_value=tick) + mocker.patch('freqtrade.exchange.bittrex._API', api_mock) ticker = get_ticker(pair='BTC_ETH') assert ticker['bid'] == 0.00001098 assert ticker['ask'] == 0.00001099 + # change the ticker + tick = {"success": True, 'result': {"Bid": 0.5, "Ask": 1, "Last": 42}} + api_mock.get_ticker = MagicMock(return_value=tick) + mocker.patch('freqtrade.exchange.bittrex._API', api_mock) + # if not caching the result we should get the same ticker ticker = get_ticker(pair='BTC_ETH', refresh=False) + print(str(ticker)) assert ticker['bid'] == 0.00001098 assert ticker['ask'] == 0.00001099 - # change the ticker - api_mock.get_ticker = MagicMock(return_value={"bid": 0, "ask": 1}) - mocker.patch('freqtrade.exchange._API', api_mock) - ticker = get_ticker(pair='BTC_ETH', refresh=True) - assert ticker['bid'] == 0 + assert ticker['bid'] == 0.5 assert ticker['ask'] == 1