feat(data): 脚手架 + YAML 配置加载
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# tests/data/__init__.py
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
# tests/data/test_config.py
|
||||
from sanguo_data.config import load_config, DataConfig
|
||||
|
||||
def test_load_config_returns_dataconfig(tmp_path):
|
||||
yaml_content = """
|
||||
data_paths:
|
||||
daily_dir: /tmp/daily
|
||||
minute_15_dir: /tmp/15min
|
||||
vnpy_db: /tmp/quant.db
|
||||
stock_list: /tmp/stock.csv
|
||||
data_sources:
|
||||
daily:
|
||||
- name: eastmoney
|
||||
enabled: true
|
||||
interval: 4.0
|
||||
validation:
|
||||
price_positive: true
|
||||
performance:
|
||||
max_retries: 3
|
||||
"""
|
||||
p = tmp_path / "config.yaml"
|
||||
p.write_text(yaml_content)
|
||||
cfg = load_config(str(p))
|
||||
assert isinstance(cfg, DataConfig)
|
||||
assert cfg.data_paths["daily_dir"] == "/tmp/daily"
|
||||
assert cfg.data_sources["daily"][0]["name"] == "eastmoney"
|
||||
assert cfg.performance["max_retries"] == 3
|
||||
Reference in New Issue
Block a user