Skip to content

Commit

Permalink
(a) specific test for #879: test_dydx__real_response_fromISO (b) simp…
Browse files Browse the repository at this point in the history
…lify test names
  • Loading branch information
trentmc committed Apr 16, 2024
1 parent 18a6a1d commit babc911
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions pdr_backend/exchange/test/test_fetch_ohlcv_dydx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@enforce_types
def test_safe_fetch_ohlcv_dydx__mocked_response():
def test_dydx__mocked_response():
# setup problem
symbol = "BTC/USD"
timeframe = "5m"
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_safe_fetch_ohlcv_dydx__mocked_response():


@enforce_types
def test_safe_fetch_ohlcv_dydx__real_response():
def test_dydx__real_response__basic():
# setup problem
symbol = "BTC/USD"
timeframe = "5m"
Expand All @@ -75,14 +75,33 @@ def test_safe_fetch_ohlcv_dydx__real_response():
tohlcv = raw_tohlcv_data[0]
assert len(tohlcv) == 6


@enforce_types
def test_dydx__real_response_fromISO():
# setup problem: 'since'
since_iso = "2024-02-27_00:00:00.000"
since_utms = UnixTimeMs.from_timestr(since_iso)
assert since_utms == 1708992000000

# setup problem: the rest
symbol = "BTC/USD"
timeframe = "5m"
limit = 1

# get result
raw_tohlcv_data = safe_fetch_ohlcv_dydx(symbol, timeframe, since, limit)
tohlcv = raw_tohlcv_data[0]

# dydx api doesn't properly address fromISO. We must fix this, see #879
# t, ohlcv = tohlcv[0], tohlcv[1:]
# assert t == 1709135400000
# assert ohlcv == "FIX ME"
t, ohlcv = tohlcv[0], tohlcv[1:]
t_utms = UnixTimeMs(t)
t_iso = t_utms.to_iso_timestr() # bad eg '2024-04-16T00:25:00.000Z'
assert t_iso == since
assert t_utms == since_utms


@enforce_types
def test_safe_fetch_ohlcv_dydx__bad_paths():
def test_dydx__bad_paths():
# setup problem
symbol = "BTC/USD"
timeframe = "5m"
Expand Down

0 comments on commit babc911

Please sign in to comment.