mirror of
https://github.com/wassname/libcryptomarket.git
synced 2026-09-09 11:25:52 +08:00
Resolved unit test issue
This commit is contained in:
@@ -5,6 +5,3 @@
|
||||
__author__ = """Gavin Chan"""
|
||||
__email__ = 'gavincyi@gmail.com'
|
||||
__version__ = '0.1.0'
|
||||
__all__ = ['api']
|
||||
|
||||
from . import api
|
||||
|
||||
@@ -56,7 +56,9 @@ def get_coinlist():
|
||||
"""
|
||||
url = API_URL + "all/coinlist"
|
||||
|
||||
return requests.get(url).json()
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
def get_histo(period, fsym, tsym, e, limit=None, toTs=None):
|
||||
@@ -94,6 +96,9 @@ def get_histo(period, fsym, tsym, e, limit=None, toTs=None):
|
||||
# The api raises a 200 for a warning, but passes a message
|
||||
rjson = r.json()
|
||||
if rjson.get("Message", None):
|
||||
logger.warning('api returned message %r, for url %r', rjson["Message"], r.url)
|
||||
logger.warning(
|
||||
'api returned message %r, for url %r',
|
||||
rjson["Message"],
|
||||
r.url)
|
||||
|
||||
return rjson
|
||||
|
||||
@@ -54,6 +54,10 @@ def test_get_instruments_cryptocompare(monkeypatch):
|
||||
}
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def raise_for_status(cls):
|
||||
pass
|
||||
|
||||
return MockReturnClass()
|
||||
|
||||
monkeypatch.setattr(requests, 'get', mockreturn)
|
||||
@@ -129,6 +133,10 @@ def test_get_historical_prices_cryptocompare(monkeypatch):
|
||||
}]
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def raise_for_status(cls):
|
||||
pass
|
||||
|
||||
return MockReturnClass()
|
||||
|
||||
monkeypatch.setattr(requests, 'get', mockreturn)
|
||||
|
||||
Reference in New Issue
Block a user