mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 23:44:16 +08:00
- 市场环境: 新增情绪周期6阶段(冰点/启动/主升/高潮/退潮/修复, 连板梯队驱动, EMA平滑+2日确认+弱档否决, 平均段长9.7天)与概念/行业主线排名(涨停梯队聚合, 可配置宽基/风格标签过滤); 市场环境页重构, regime 透明加列, 与5档state并存 - 挖掘: 因子与策略挖掘全链路(API/worker/进程锁/候选库/前端工作台/文档), 周度调度默认关闭且永不自动发布 - 回测: 财务快照因子(点时口径), 批量回测预计算共享下期收益, 信号路径矩阵列依赖展开修复(consecutive_limit_ups 缺列报错) - 数据/性能: enriched 生成与预热治理, 重任务限流, 行情/K线缓存复用, 时区修复 - 测试: 后端全量 914 通过; GUI 黑盒验证截图存证 gui-test-screenshots/
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from app.api import settings
|
|
|
|
|
|
def test_mining_schedule_model_is_strict_and_forbids_extra_fields():
|
|
valid = settings.MiningSchedulePrefs(
|
|
mining_schedule_enabled=True,
|
|
mining_schedule_weekday=4,
|
|
mining_budget_profile="strict",
|
|
)
|
|
assert valid.model_dump() == {
|
|
"mining_schedule_enabled": True,
|
|
"mining_schedule_weekday": 4,
|
|
"mining_budget_profile": "strict",
|
|
}
|
|
|
|
invalid_payloads = [
|
|
{
|
|
"mining_schedule_enabled": "true",
|
|
"mining_schedule_weekday": 4,
|
|
"mining_budget_profile": "balanced",
|
|
},
|
|
{
|
|
"mining_schedule_enabled": True,
|
|
"mining_schedule_weekday": 5,
|
|
"mining_budget_profile": "balanced",
|
|
},
|
|
{
|
|
"mining_schedule_enabled": True,
|
|
"mining_schedule_weekday": 4,
|
|
"mining_budget_profile": "exploratory",
|
|
},
|
|
{
|
|
"mining_schedule_enabled": True,
|
|
"mining_schedule_weekday": 4,
|
|
"mining_budget_profile": "balanced",
|
|
"unknown": True,
|
|
},
|
|
]
|
|
for payload in invalid_payloads:
|
|
with pytest.raises(ValidationError):
|
|
settings.MiningSchedulePrefs.model_validate(payload)
|
|
|
|
|
|
def test_update_mining_schedule_calls_group_setter_once(monkeypatch):
|
|
calls = []
|
|
monkeypatch.setattr(
|
|
"app.services.preferences.set_mining_schedule",
|
|
lambda enabled, weekday, profile: (
|
|
calls.append((enabled, weekday, profile))
|
|
or {
|
|
"mining_schedule_enabled": enabled,
|
|
"mining_schedule_weekday": weekday,
|
|
"mining_budget_profile": profile,
|
|
}
|
|
),
|
|
)
|
|
request = settings.MiningSchedulePrefs(
|
|
mining_schedule_enabled=True,
|
|
mining_schedule_weekday=1,
|
|
mining_budget_profile="strict",
|
|
)
|
|
|
|
result = settings.update_mining_schedule(request)
|
|
|
|
assert calls == [(True, 1, "strict")]
|
|
assert result["mining_budget_profile"] == "strict"
|