fix(market-data): 增加同步进度日志并修复生产目录权限
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import logging
|
||||
from collections.abc import Generator, Iterable, Sequence
|
||||
from contextlib import contextmanager
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from zhixing_server.modules.market_data.application.sync import (
|
||||
SyncMarketData,
|
||||
SyncMarketDataCommand,
|
||||
@@ -163,3 +166,38 @@ def test_sync_is_idempotent_and_reports_coverage(tmp_path: Path) -> None:
|
||||
assert second.status == "success"
|
||||
assert second.inserted_count == 1
|
||||
assert second.unchanged_count >= 2
|
||||
|
||||
|
||||
def test_sync_logs_progress_for_initialize_and_daily_update(
|
||||
tmp_path: Path,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
target = date(2024, 1, 2)
|
||||
repository = InMemoryRepository()
|
||||
use_case = SyncMarketData(
|
||||
FakeSource(target),
|
||||
CsvSnapshotStore(tmp_path),
|
||||
repository,
|
||||
today=target,
|
||||
)
|
||||
caplog.set_level(logging.INFO, logger="zhixing_server.modules.market_data.application.sync")
|
||||
|
||||
initialize = use_case.execute(
|
||||
SyncMarketDataCommand(mode="initialize", target_trade_date=target)
|
||||
)
|
||||
initialize_messages = [record.getMessage() for record in caplog.records]
|
||||
|
||||
assert initialize.status == "success"
|
||||
assert any("stage=daily_basic" in message for message in initialize_messages)
|
||||
assert any(
|
||||
"stage=bar" in message and "progress=1/1" in message
|
||||
for message in initialize_messages
|
||||
)
|
||||
|
||||
caplog.clear()
|
||||
daily = use_case.execute(SyncMarketDataCommand(mode="daily", target_trade_date=target))
|
||||
daily_messages = [record.getMessage() for record in caplog.records]
|
||||
|
||||
assert daily.status == "success"
|
||||
assert any("market_data_sync_started mode=daily" in message for message in daily_messages)
|
||||
assert any("market_data_sync_finished" in message for message in daily_messages)
|
||||
|
||||
Reference in New Issue
Block a user