# app/tests/unit/market_data/acquisition/handlers/test_candles_handler.py

from __future__ import annotations

from src.market_data.acquisition.handlers.candles_handler import (
    DzengiCandlesDocumentHandler,
)


def test_handle_candles_document_runs_complete_pipeline() -> None:
    handler = DzengiCandlesDocumentHandler()

    result = handler.handle_candles_document(
        {
            "payload": {
                "klines": [
                    [2000, "101", "111", "91", "106", "13"],
                    [1000, "100", "110", "90", "105", "12"],
                ]
            }
        },
        symbol="BTC/USD",
        interval="1m",
        source="rest_klines:bid",
    )

    assert len(result) == 2
    assert [item.open_time.timestamp() for item in result] == [1, 2]
    assert all(item.symbol == "BTC/USD" for item in result)
    assert all(item.interval == "1m" for item in result)
    assert all(item.source == "rest_klines:bid" for item in result)
