Skip to content

Commit

Permalink
adding OHLC tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lockefox committed Sep 27, 2017
1 parent 31f6f1d commit 3e535ce
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def find_uniques(
unique_test = list(set(test_list) - set(expected_list))
print('Unique test vals: {}'.format(unique_test))

#unique_expected = list(expected_list)
#for key in test_list:
# try:
# unique_expected.remove(key)
# print('removed key: {}'.format(key))
# except Exception:
# print('key not in expected: {}'.format(key))
# pass
#print(unique_expected)
unique_expected = list(set(expected_list) - set(test_list))
print('Unique expected vals: {}'.format(unique_expected))

Expand Down
90 changes: 90 additions & 0 deletions tests/test_coins_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,96 @@ def test_get_histo_day_cc_badcoin(self):
'BUTTS',
self.limit
)

class TestGetOHLCCC:
"""validate behavior for get_ohlc_cc()"""
coin = 'BTC'
limit = 60
max_limit = 2001
expected_headers = [
'high', 'open', 'time', 'volumefrom', 'low', 'close', 'volumeto'
]

def test_get_ohlc_cc_happypath(self):
"""validate expected default behavor for endpoint"""
data = prices.get_ohlc_cc(
self.coin,
self.limit
)

assert isinstance(data, pandas.DataFrame)

unique_values, unique_expected = helpers.find_uniques(
list(data.columns.values),
self.expected_headers
)
assert unique_expected == []
if unique_values:
pytest.xfail(
'Unexpected values from get_ohlc_cc(): {}'.format(unique_values)
)

def test_get_ohlc_cc_maxrange(self):
"""make sure expected failure for too much data requested"""
requested_limit = self.max_limit + 10
data = prices.get_ohlc_cc(
self.coin,
requested_limit
)
if data.shape[0] > self.max_limit:
pytest.xfail('Max limit unexpected. Expected={} Requested={} Returned={}'.format(
self.max_limit, requested_limit, data.shape[0]
))

def test_get_ohlc_cc_hours(self):
"""request hours data"""
data = prices.get_ohlc_cc(
self.coin,
self.limit,
frequency='hour'
)

assert isinstance(data, pandas.DataFrame)

unique_values, unique_expected = helpers.find_uniques(
list(data.columns.values),
self.expected_headers
)
assert unique_expected == []
if unique_values:
pytest.xfail(
'Unexpected values from get_ohlc_cc(frequency=hour): {}'.format(unique_values)
)

def test_get_ohlc_cc_seconds(self):
"""request minute data"""
data = prices.get_ohlc_cc(
self.coin,
self.limit,
frequency='minute'
)

assert isinstance(data, pandas.DataFrame)

unique_values, unique_expected = helpers.find_uniques(
list(data.columns.values),
self.expected_headers
)
assert unique_expected == []
if unique_values:
pytest.xfail(
'Unexpected values from get_ohlc_cc(frequency=minute): {}'.format(unique_values)
)

def test_get_ohlc_cc_badfreq(self):
"""ask for bad frequency"""
with pytest.raises(ValueError):
data = prices.get_ohlc_cc(
self.coin,
self.limit,
frequency='eons'
)

@flaky
def test_get_ticker_single():
"""validate get_ticker_hitbtc() returns valid schema"""
Expand Down

0 comments on commit 3e535ce

Please sign in to comment.