test_generic_skill_catalog.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from pathlib import Path
  2. SKILL_DIR = Path(__file__).parents[1] / ".agents" / "skills" / "query-odps-data"
  3. def test_generic_skill_is_chinese_and_requires_catalog() -> None:
  4. skill = (SKILL_DIR / "SKILL.md").read_text(encoding="utf-8")
  5. assert "# 通用 ODPS 数据查询" in skill
  6. assert "references/data-catalog.md" in skill
  7. assert "目录未收录的表或字段" in skill
  8. def test_catalog_covers_all_confirmed_tables() -> None:
  9. catalog = (SKILL_DIR / "references" / "data-catalog.md").read_text(encoding="utf-8")
  10. tables = {
  11. "loghubods.useractive_log",
  12. "loghubods.useractive_log_per5min",
  13. "loghubods.video_action_log_applet",
  14. "loghubods.video_action_log_flow",
  15. "loghubods.video_action_log_per5min",
  16. "loghubods.video_play_log",
  17. "loghubods.video_play_log_per5min",
  18. "loghubods.user_share_log",
  19. "loghubods.user_share_log_per5min",
  20. "loghubods.simpleevent_log",
  21. "loghubods.simpleevent_log_flow",
  22. "loghubods.ad_action_log_own",
  23. "loghubods.ad_action_log_own_per5min",
  24. "loghubods.operation_log_per5min",
  25. "videoods.dim_video",
  26. }
  27. assert all(f"`{table}`" in catalog for table in tables)
  28. assert "禁止改用物理列 `rootsessionid`" in catalog
  29. assert "未收录的字段不得按名称猜测含义" in catalog
  30. def test_catalog_distinguishes_flow_and_per5min_partitions() -> None:
  31. catalog = (SKILL_DIR / "references" / "data-catalog.md").read_text(encoding="utf-8")
  32. assert "`dt LIKE 'yyyyMMdd%'`" in catalog
  33. assert "`year='yyyy'`" in catalog
  34. assert "`month='MM'`" in catalog
  35. assert "`dt='DD'`" in catalog