chart/tests/test_runtime_start.py

30 lines
837 B
Python

import asyncio
from unittest.mock import AsyncMock
from app.bars.models import Timeframe
from app.config import Settings
from app.runtime import Runtime
def test_start_seeds_native_thirty_minute_history(tmp_path, monkeypatch):
instance = Runtime(Settings(manual_lines_path=tmp_path / "manual_lines.json"))
source = object()
monkeypatch.setattr("app.runtime.seed_source", lambda settings: source)
instance.stream.seed = AsyncMock()
async def run():
return None
instance.stream.run = run
async def start():
task = await instance.start()
await task
asyncio.run(start())
assert [call.args[1:4] for call in instance.stream.seed.await_args_list] == [
(Timeframe.H1, "730d", "ES=F"),
(Timeframe.M30, "60d", "ES=F"),
(Timeframe.M1, "8d", "ES=F"),
]