feat(db): add video pages and up follower snapshot schema
This commit is contained in:
1 parent
707ed7d7d7
commit
4942d1d161
10 files changed
+521
-13
No files matched your search
+44
-1
@@ -126,12 +126,55 @@ def test_invalid_values():
|
||||
raise AssertionError("非法环境变量必须拒绝")
|
||||
|
||||
|
||||
def test_analytics_defaults_and_validation():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "config.json"
|
||||
write(path, base_config())
|
||||
cfg = load_config(path, env={})
|
||||
assert cfg.analytics.min_duration_seconds == 600
|
||||
assert cfg.analytics.maturity_days == 14
|
||||
assert cfg.analytics.min_view_for_efficiency == 0
|
||||
assert cfg.analytics.shrink_minutes is None
|
||||
|
||||
data = base_config()
|
||||
data["analytics"] = {
|
||||
"min_duration_seconds": 300,
|
||||
"maturity_days": 7,
|
||||
"min_view_for_efficiency": 100,
|
||||
"shrink_minutes": 90,
|
||||
}
|
||||
write(path, data)
|
||||
cfg = load_config(path, env={})
|
||||
assert cfg.analytics.min_duration_seconds == 300
|
||||
assert cfg.analytics.maturity_days == 7
|
||||
assert cfg.analytics.min_view_for_efficiency == 100
|
||||
assert cfg.analytics.shrink_minutes == 90
|
||||
|
||||
for bad, hint in (
|
||||
({"min_duration_seconds": -1}, "min_duration_seconds"),
|
||||
({"maturity_days": -1}, "maturity_days"),
|
||||
({"min_view_for_efficiency": -1}, "min_view_for_efficiency"),
|
||||
({"shrink_minutes": 0}, "shrink_minutes"),
|
||||
({"shrink_minutes": "auto"}, "shrink_minutes"),
|
||||
):
|
||||
data = base_config()
|
||||
data["analytics"] = bad
|
||||
write(path, data)
|
||||
try:
|
||||
load_config(path, env={})
|
||||
except ConfigError as exc:
|
||||
assert hint in str(exc), (bad, str(exc))
|
||||
else:
|
||||
raise AssertionError(f"非法 analytics 必须拒绝: {bad}")
|
||||
|
||||
|
||||
def main():
|
||||
test_dual_accounts_and_env_override()
|
||||
test_flat_and_missing_account_rejected()
|
||||
test_validation_require_read_auth_and_hot_reload()
|
||||
test_invalid_values()
|
||||
print("OK: 双账号配置加载、拒绝 flat 格式、ENV 覆盖与热加载测试全部通过")
|
||||
test_analytics_defaults_and_validation()
|
||||
print("OK: 双账号配置加载、拒绝 flat 格式、ENV 覆盖、热加载与 analytics 测试全部通过")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user