With a better unit test thanks @glonlas

This commit is contained in:
Jean-Baptiste LE STANG 2018-01-21 14:25:15 +01:00
parent 960d088deb
commit c0d3ac5534
2 changed files with 46 additions and 0 deletions

View File

@ -196,6 +196,7 @@ def ticker_history():
"C": 8.88e-05,
"V": 991.09056638,
"T": "2017-11-26T08:50:00",
"BV": 0.0877869
},
{
"O": 8.88e-05,
@ -204,6 +205,7 @@ def ticker_history():
"C": 8.893e-05,
"V": 658.77935965,
"T": "2017-11-26T08:55:00",
"BV": 0.05874751
},
{
"O": 8.891e-05,
@ -212,5 +214,36 @@ def ticker_history():
"C": 8.877e-05,
"V": 7920.73570705,
"T": "2017-11-26T09:00:00",
"BV": 0.7039405
}
]
@pytest.fixture
def ticker_history_without_bv():
return [
{
"O": 8.794e-05,
"H": 8.948e-05,
"L": 8.794e-05,
"C": 8.88e-05,
"V": 991.09056638,
"T": "2017-11-26T08:50:00"
},
{
"O": 8.88e-05,
"H": 8.942e-05,
"L": 8.88e-05,
"C": 8.893e-05,
"V": 658.77935965,
"T": "2017-11-26T08:55:00"
},
{
"O": 8.891e-05,
"H": 8.893e-05,
"L": 8.875e-05,
"C": 8.877e-05,
"V": 7920.73570705,
"T": "2017-11-26T09:00:00"
}
]

View File

@ -72,3 +72,16 @@ def test_get_signal_handles_exceptions(mocker):
side_effect=Exception('invalid ticker history '))
assert get_signal('BTC-ETH', 5) == (False, False)
def test_parse_ticker_dataframe(ticker_history, ticker_history_without_bv):
columns = ['close', 'high', 'low', 'open', 'date', 'volume']
# Test file with BV data
dataframe = parse_ticker_dataframe(ticker_history)
assert dataframe.columns.tolist() == columns
# Test file without BV data
dataframe = parse_ticker_dataframe(ticker_history_without_bv)
assert dataframe.columns.tolist() == columns