微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
@@ -22,3 +22,32 @@ def test_config_get_nested():
|
||||
config = AppConfig.load({"app": {"store_id": 1}})
|
||||
assert config.get("db.batch_size") == 1000
|
||||
assert config.get("nonexistent.key", "default") == "default"
|
||||
|
||||
|
||||
def test_business_day_start_hour_default():
|
||||
"""默认值 8 应正常加载"""
|
||||
config = AppConfig.load({"app": {"store_id": 1}})
|
||||
assert config.get("app.business_day_start_hour") == 8
|
||||
|
||||
|
||||
def test_business_day_start_hour_valid_range():
|
||||
"""0–23 范围内的整数应正常加载"""
|
||||
for h in (0, 12, 23):
|
||||
config = AppConfig.load({"app": {"store_id": 1, "business_day_start_hour": h}})
|
||||
assert config.get("app.business_day_start_hour") == h
|
||||
|
||||
|
||||
def test_business_day_start_hour_out_of_range():
|
||||
"""超出 0–23 范围应抛出 SystemExit"""
|
||||
with pytest.raises(SystemExit, match="business_day_start_hour"):
|
||||
AppConfig.load({"app": {"store_id": 1, "business_day_start_hour": 24}})
|
||||
with pytest.raises(SystemExit, match="business_day_start_hour"):
|
||||
AppConfig.load({"app": {"store_id": 1, "business_day_start_hour": -1}})
|
||||
|
||||
|
||||
def test_business_day_start_hour_non_int():
|
||||
"""非整数类型应抛出 SystemExit"""
|
||||
with pytest.raises(SystemExit, match="business_day_start_hour"):
|
||||
AppConfig.load({"app": {"store_id": 1, "business_day_start_hour": "8"}})
|
||||
with pytest.raises(SystemExit, match="business_day_start_hour"):
|
||||
AppConfig.load({"app": {"store_id": 1, "business_day_start_hour": 8.0}})
|
||||
|
||||
Reference in New Issue
Block a user