test_ontology_frontend_contract.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. from pathlib import Path
  2. ROOT = Path(__file__).resolve().parents[2]
  3. def test_vue2_ontology_center_routes_and_api_contract_exist():
  4. routes = (ROOT / "frontend/src/router/routes.js").read_text(encoding="utf-8")
  5. api = (ROOT / "frontend/src/api/dataDevelopment.js").read_text(encoding="utf-8")
  6. request = (ROOT / "frontend/src/utils/request.js").read_text(encoding="utf-8")
  7. index = (ROOT / "frontend/src/views/dataGovernance/ontology/index.vue").read_text(encoding="utf-8")
  8. workbench = "".join(
  9. path.read_text(encoding="utf-8")
  10. for path in (
  11. ROOT / "frontend/src/views/dataGovernance/ontology/workbench.vue",
  12. ROOT
  13. / "frontend/src/views/dataGovernance/ontology/components/GraphSectionEditor.vue",
  14. ROOT
  15. / "frontend/src/views/dataGovernance/ontology/components/VersionWorkspace.vue",
  16. ROOT
  17. / "frontend/src/views/dataGovernance/ontology/components/SuggestionReviewDialog.vue",
  18. )
  19. )
  20. assert "ontologyCenter" in routes
  21. assert "dataGovernance/ontology/index" in routes
  22. assert "dataGovernance/ontology/workbench" in routes
  23. workbench_route = routes[routes.index("path: '/data-governance/ontology/:uid'") :]
  24. workbench_route = workbench_route[: workbench_route.index("alwaysShow: 0")]
  25. assert "roles: ['viewer', 'editor', 'admin']" in workbench_route
  26. for name in (
  27. "getOntologies",
  28. "getOntology",
  29. "getOntologyGraph",
  30. "getOntologyVersions",
  31. "createOntology",
  32. "validateOntology",
  33. "publishOntology",
  34. "diffOntology",
  35. "rollbackOntology",
  36. "getDataElements",
  37. "reviewOntologyChangeSet",
  38. "importOntology",
  39. "exportOntology",
  40. ):
  41. assert name in api
  42. assert "patch (url, params, config = {})" in request
  43. assert request.count("...(config.headers || {})") >= 2
  44. assert "本体中心" in index
  45. assert "选择业务域" in index
  46. for label in (
  47. "概念",
  48. "属性",
  49. "关系",
  50. "约束",
  51. "业务域",
  52. "数据元素映射",
  53. "版本历史",
  54. "版本差异",
  55. "动态建议",
  56. "导入",
  57. "导出",
  58. "发布确认",
  59. "高级 JSON",
  60. ):
  61. assert label in workbench
  62. assert "canEditOntology" in workbench
  63. assert "canPublishOntology" in workbench
  64. assert "loadOntology" in workbench
  65. assert "loadVersions" in workbench
  66. assert "'$route.params.uid'" in workbench
  67. combined = api + index + workbench
  68. assert "MINIO_PASSWORD" not in combined
  69. assert "NEO4J_PASSWORD" not in combined
  70. assert "DEEPSEEK_API_KEY" not in combined
  71. def test_ontology_workbench_uses_focused_editor_components():
  72. component_root = (
  73. ROOT / "frontend/src/views/dataGovernance/ontology/components"
  74. )
  75. editor = (component_root / "GraphSectionEditor.vue").read_text(
  76. encoding="utf-8"
  77. )
  78. versions = (component_root / "VersionWorkspace.vue").read_text(
  79. encoding="utf-8"
  80. )
  81. suggestions = (component_root / "SuggestionReviewDialog.vue").read_text(
  82. encoding="utf-8"
  83. )
  84. assert "新增" in editor and "编辑" in editor and "删除" in editor
  85. assert "查看差异" in versions and "回滚" in versions
  86. assert "置信度" in suggestions and "证据" in suggestions
  87. assert "接受" in suggestions and "拒绝" in suggestions