test_data_rule_frontend_contract.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. from pathlib import Path
  2. API = Path("frontend/src/api/dataRules.js")
  3. AUTHORING = Path("frontend/src/components/DataRules/RuleAuthoringPanel.vue")
  4. CATALOG = Path("frontend/src/components/DataRules/RuleCatalogPicker.vue")
  5. EVIDENCE = Path("frontend/src/components/DataRules/CompilationEvidence.vue")
  6. ASSEMBLER = Path(
  7. "frontend/src/components/DataRules/ProductionLineAssembler.vue"
  8. )
  9. STANDARD = Path(
  10. "frontend/src/views/dataGovernance/dataStandard/components/edit.vue"
  11. )
  12. DATAFLOW = Path(
  13. "frontend/src/views/dataGovernance/dataProcess/components/edit.vue"
  14. )
  15. FACTORY = Path(
  16. "frontend/src/views/dataFactory/workflow/ProductionLineDeployment.vue"
  17. )
  18. FACTORY_INDEX = Path("frontend/src/views/dataFactory/workflow/index.vue")
  19. def test_rule_api_client_exposes_versions_publish_and_server_side_release():
  20. source = API.read_text(encoding="utf-8")
  21. assert "http.get('/rules/capabilities')" in source
  22. assert "http.post('/rules/interpret'" in source
  23. assert "http.post('/rules/validate'" in source
  24. assert "http.post('/rules/production-lines/resolve'" in source
  25. assert "http.post('/rules/rule-versions'" in source
  26. assert "http.post(`/rules/rule-versions/${versionId}/publish`)" in source
  27. assert "http.post(`/rules/rule-versions/${versionId}/validate`" in source
  28. assert "http.post(`/rules/rule-versions/${versionId}/test`" in source
  29. assert "http.get('/rules/catalog'" in source
  30. assert "/rules/catalog/assets/${assetType}/${versionId}/evidence" in source
  31. assert "http.post('/rules/standard-versions'" in source
  32. assert "http.post(`/rules/standard-versions/${versionId}/publish`)" in source
  33. assert "http.post(`/rules/production-lines/${dataflowUid}/release`" in source
  34. assert "/activate" not in source
  35. def test_reusable_authoring_panel_preserves_human_review_gate():
  36. source = AUTHORING.read_text(encoding="utf-8")
  37. assert "authoringSurface" in source
  38. assert "interpretRule" in source
  39. assert "clarification_required" in source
  40. assert "$emit('candidate'" in source
  41. assert "createRuleVersion" in source
  42. assert "createStandardVersion" in source
  43. assert "publishRuleVersion" in source
  44. assert "rules:publish" in source
  45. assert "$emit('version'" in source
  46. assert "自动执行" not in source
  47. def test_authoring_panel_exposes_governed_ai_lifecycle_without_code_editor():
  48. source = AUTHORING.read_text(encoding="utf-8")
  49. for token in [
  50. "schemaContextReady",
  51. "generation_receipt",
  52. "assumptions",
  53. "ambiguities",
  54. "modelProvenance",
  55. "validateRuleVersion",
  56. "testRuleVersion",
  57. "CompilationEvidence",
  58. ]:
  59. assert token in source
  60. assert "candidatePreview" not in source
  61. assert "<pre>{{ candidate" not in source
  62. def test_catalog_picker_selects_fixed_published_asset_versions():
  63. source = CATALOG.read_text(encoding="utf-8")
  64. for token in [
  65. "searchPublishedCatalog",
  66. "assetType",
  67. "published",
  68. "schema_compatibility",
  69. "latest_evidence",
  70. "v-skeleton-loader",
  71. "aria-label",
  72. "keydown",
  73. ]:
  74. assert token in source
  75. assert "$emit('input', item.id)" in source
  76. assert "item.name" in source
  77. assert "rule_uid" in source
  78. assert "standard_uid" in source
  79. def test_compilation_evidence_shows_trusted_chain_without_sensitive_payloads():
  80. source = EVIDENCE.read_text(encoding="utf-8")
  81. for token in [
  82. "generation",
  83. "logical_compile",
  84. "dry_run",
  85. "publication",
  86. "physical",
  87. "getRuleVersionEvidence",
  88. ]:
  89. assert token in source
  90. for forbidden in ["raw_sample", "secret", "password", "token"]:
  91. assert forbidden not in source.lower()
  92. def test_standard_links_published_rules_and_keeps_legacy_code_read_only():
  93. standard = STANDARD.read_text(encoding="utf-8")
  94. assert 'authoring-surface="data_standard"' in standard
  95. assert '@version="handleRuleVersion"' in standard
  96. assert "RuleCatalogPicker" in standard
  97. assert "rule_version_id" in standard
  98. assert "legacyMigration" in standard
  99. assert "readonly" in standard
  100. assert "迁移" in standard
  101. assert "dataStandardCodeGenerate" not in standard
  102. assert "handleCodeGenerate" not in standard
  103. def test_dataflow_assembler_uses_published_catalog_ids_without_inline_rules():
  104. source = ASSEMBLER.read_text(encoding="utf-8")
  105. dataflow = DATAFLOW.read_text(encoding="utf-8")
  106. assert "RuleCatalogPicker" in source
  107. assert "standard_version_id" in source
  108. assert "rule_version_id" in source
  109. assert "schema_compatibility" in source
  110. assert "releaseReadiness" in source
  111. assert "component_kind" in source
  112. assert "rule_spec" not in source
  113. assert "operation_code" not in source
  114. assert "ProductionLineAssembler" in dataflow
  115. assert "dataflow_spec" in dataflow
  116. assert "migration_metadata" in dataflow
  117. assert "rule_spec" not in dataflow
  118. assert "v-model=\"changeObj.rule\"" not in dataflow
  119. assert "handleRuleCandidate" not in dataflow
  120. def test_data_factory_exposes_release_ready_but_no_fake_activation():
  121. page = FACTORY.read_text(encoding="utf-8")
  122. index = FACTORY_INDEX.read_text(encoding="utf-8")
  123. assert "数据生产线投产" in page
  124. assert "getRuleCapabilities" in page
  125. assert "production_line_release" in page
  126. assert "data_factory_activation" in page
  127. assert "发布版本" in page
  128. assert "执行计划" in page
  129. assert "发布与执行计划已经可用" in page
  130. assert "投产激活仍保持关闭" in page
  131. assert "ProductionLineDeployment" in index