rebuild(migration): validate local legacy cutover
This commit is contained in:
@@ -475,6 +475,7 @@ def test_sentiment_has_all_weighted_components_and_extreme_risk_cap() -> None:
|
||||
sentiment = calculate_sentiment(snapshot, [])
|
||||
assert sentiment["score"] <= 15
|
||||
assert sentiment["phase"] == "冰点"
|
||||
assert sentiment["stats"]["yesterday_count"] == 0
|
||||
assert {item["key"]: item["weight"] for item in sentiment["components"]} == {
|
||||
"breadth": 20,
|
||||
"limit_ecology": 25,
|
||||
@@ -551,3 +552,53 @@ def test_incomplete_daily_snapshot_is_rejected_without_overwriting(tmp_path) ->
|
||||
service.sync("2026-07-29", datetime(2026, 7, 30, 16, tzinfo=SHANGHAI))
|
||||
with database.read() as connection:
|
||||
assert repository.latest_summary(connection, "2026-07-29") is None
|
||||
|
||||
|
||||
def test_synced_snapshot_keeps_event_lists_separate_from_overview_counts(tmp_path) -> None:
|
||||
database = Database(tmp_path / "sync-complete.db")
|
||||
MigrationRunner(database).upgrade(MIGRATIONS)
|
||||
repository = MarketRepository()
|
||||
with database.transaction() as connection:
|
||||
repository.replace_calendar(
|
||||
connection,
|
||||
(
|
||||
{"cal_date": "20260728", "is_open": 1, "pretrade_date": "20260727"},
|
||||
{"cal_date": "20260729", "is_open": 1, "pretrade_date": "20260728"},
|
||||
),
|
||||
"tushare",
|
||||
"2026-07-29T15:00:00+08:00",
|
||||
)
|
||||
repository.replace_stocks(
|
||||
connection,
|
||||
({
|
||||
"ts_code": "000001.SZ", "symbol": "000001", "name": "平安银行",
|
||||
"industry": "银行", "list_status": "L",
|
||||
},),
|
||||
"tushare",
|
||||
"2026-07-29T15:00:00+08:00",
|
||||
)
|
||||
provider = TushareProvider("test-token")
|
||||
stock = {
|
||||
"ts_code": "000001.SZ", "name": "平安银行", "industry": "银行",
|
||||
"close": 10, "pct_chg": 5, "amount": 100, "limit_times": 1,
|
||||
}
|
||||
provider.snapshot_inputs = lambda *_: {
|
||||
"daily": calculation_result([stock]),
|
||||
"limit_up": calculation_result([]),
|
||||
"limit_down": calculation_result([]),
|
||||
"broken": calculation_result([stock]),
|
||||
"previous_limit_up": calculation_result([]),
|
||||
"price_limits": calculation_result([{"ts_code": "000001.SZ", "up_limit": 11}]),
|
||||
}
|
||||
service = MarketSnapshotService(
|
||||
database,
|
||||
repository,
|
||||
DataGateway(database, repository, (provider,), DataSourcePolicy()),
|
||||
)
|
||||
service.sync("2026-07-29", datetime(2026, 7, 30, 16, tzinfo=SHANGHAI))
|
||||
|
||||
broken = service.workspace("broken", "2026-07-29")
|
||||
emotion = service.workspace("emotion", "2026-07-29")
|
||||
assert len(broken["items"]) == 1
|
||||
assert broken["items"][0]["identifier"] == "000001.SZ"
|
||||
assert emotion["overview"]["broken"] == 1
|
||||
|
||||
Reference in New Issue
Block a user