Skip to content

Commit 1ad7810

Browse files
committed
Test and implement single market data differently.
1 parent f391841 commit 1ad7810

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Cryptsy.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,18 @@ def _api_query(self, method, request_data={}):
4040

4141
return json.loads(rv.read())
4242

43-
def market_data(self, v2=False):
43+
def market_data(self, marketid=None, v2=False):
4444
""" Get market data for all markets.
4545
4646
Defaults to the old version of getmarketdata. Set v2 to True to use
4747
getmarketdatav2.
4848
"""
4949
if v2 is True:
5050
return self._public_api_query("marketdatav2")
51+
if marketid is not None:
52+
return self._public_api_query("singlemarketdata", marketid=marketid)
5153
return self._public_api_query("marketdata")
5254

53-
def single_market_data(self, marketid=None):
54-
""" Get general market data for the given market.
55-
56-
:param marketid: Market ID you are querying for.
57-
"""
58-
return self._public_api_query("singlemarketdata", marketid=marketid)
59-
6055
def order_book_data(self, marketid=None):
6156
""" Get orderbook data for all markets, or for a single one.
6257

test_cryptsy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ def test_generate_new_address_currencyid(api, api_query_mock):
9999
})
100100

101101

102+
def test_single_market_data(api, public_api_query_mock):
103+
""" Should call singlemarketdata if marketid is provided. """
104+
api.market_data(marketid=10)
105+
public_api_query_mock.assert_called_with('singlemarketdata', marketid=10)
106+
107+
102108
def test_market_data_old(api, public_api_query_mock):
103109
""" Should use the old marketdata method if v2 is not set to True. """
104110
api.market_data()

0 commit comments

Comments
 (0)