Show 30-minute candles on the last-24-hours chart
pull-request / validate (pull_request) Successful in 2m34s
pull-request / validate (pull_request) Successful in 2m34s
This commit is contained in:
@@ -107,3 +107,22 @@ def test_version_endpoint(monkeypatch):
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"version": "abc1234"}
|
||||
|
||||
|
||||
def test_24_hour_chart_uses_half_hour_candles():
|
||||
response = TestClient(main.app).get("/")
|
||||
assert "24h Candles (30m)" in response.text
|
||||
assert "initChart('chart-hour', '/api/kraken-half-hour', 5 * 60 * 1000, updateMidnightPrice)" in response.text
|
||||
assert "initChart('chart-minute', '/api/kraken-minute', 60 * 1000)" in response.text
|
||||
|
||||
|
||||
def test_half_hour_proxy_preserves_candles_and_upstream_errors(monkeypatch):
|
||||
for status, payload in [(200, [{"ts": 1800, "open": "10", "high": "12", "low": "9", "close": "11"}]), (503, {"error": "database unavailable"})]:
|
||||
request = httpx.Request("GET", "http://btcdata.test/api/kraken-half-hour")
|
||||
client = StubAsyncClient(response=httpx.Response(status, json=payload, request=request))
|
||||
monkeypatch.setattr(main, "BTCDATA_URL", "http://btcdata.test")
|
||||
monkeypatch.setattr(main.httpx, "AsyncClient", lambda: client)
|
||||
response = TestClient(main.app).get("/api/kraken-half-hour")
|
||||
assert response.status_code == status
|
||||
assert response.json() == payload
|
||||
assert client.requested_url == "http://btcdata.test/api/kraken-half-hour"
|
||||
|
||||
Reference in New Issue
Block a user