archive(provider-pipeline): preserve final B2 audit and mapping evidence
This commit is contained in:
72
tests/test_style_layer_isolation_audit.py
Normal file
72
tests/test_style_layer_isolation_audit.py
Normal file
@@ -0,0 +1,72 @@
|
||||
"""B2.7 全量 Style Layer 归属审核:不同 Provider、混合 Layer、纯 residual、无观测。"""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location("isolation",ROOT/"tools/provider-pipeline/style_layer_isolation_audit.py")
|
||||
audit = importlib.util.module_from_spec(spec)
|
||||
assert spec and spec.loader
|
||||
spec.loader.exec_module(audit)
|
||||
|
||||
|
||||
def assignment(oid, index, source_layer, status, standard):
|
||||
return {
|
||||
"visualObjectId": oid, "status": status, "standardLayer": standard,
|
||||
"renderEvidence": {
|
||||
"sourceLayer": source_layer,
|
||||
"components": [{"styleIndex": index,"styleLayerId": "original-layer", "role": "icon", "resourceKey": "R"}],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class IsolationTests(unittest.TestCase):
|
||||
def test_two_different_provider_source_names_one_class_is_candidate_only(self):
|
||||
for name in ("raw-pbf-a", "provider-b-features"):
|
||||
with self.subTest(name=name):
|
||||
style={"layers":[{"id":"original-layer","source":"provider","source-layer":name},
|
||||
{"id":"unused","source":"provider","source-layer":"other"}]}
|
||||
mapping={"assignments":[assignment("A",0,name,"LAYER_ONLY","marks"),
|
||||
assignment("B",0,name,"VISUAL_OBJECT_MATCH","marks")]}
|
||||
out=audit.audit_isolation(style,mapping,2)
|
||||
self.assertEqual(out["layerCategoryCounts"],{
|
||||
"NO_OBSERVED_STYLE_FEATURES":1,
|
||||
"ONE_STANDARD_IN_COMPLETE_CATALOG_CANDIDATE":1,
|
||||
})
|
||||
self.assertTrue(out["layers"][0]["possibleWholeLayerVisibilityInFrozenSnapshot"])
|
||||
self.assertFalse(out["layers"][0]["productionWholeLayerVisibilityAuthorized"])
|
||||
self.assertEqual(out["runtimeAuthorizationCount"],0)
|
||||
|
||||
def test_mixed_known_and_unknown_never_authorized(self):
|
||||
style={"layers":[{"id":"original-layer","source":"A","source-layer":"shared"}]}
|
||||
mapping={"assignments":[assignment("A",0,"shared","LAYER_ONLY","marks"),
|
||||
assignment("B",0,"shared","UNKNOWN",None)]}
|
||||
out=audit.audit_isolation(style,mapping,2)
|
||||
self.assertEqual(out["layerCategoryCounts"],{"MIXED_OR_RESIDUAL":1})
|
||||
self.assertFalse(out["layers"][0]["possibleWholeLayerVisibilityInFrozenSnapshot"])
|
||||
|
||||
def test_only_unknown_is_different_from_mixed(self):
|
||||
style={"layers":[{"id":"original-layer","source":"A","source-layer":"shared"}]}
|
||||
mapping={"assignments":[assignment("A",0,"shared","UNKNOWN",None)]}
|
||||
out=audit.audit_isolation(style,mapping,1)
|
||||
self.assertEqual(out["layerCategoryCounts"],{"ONLY_UNRESOLVED_OR_RESIDUAL":1})
|
||||
|
||||
def test_conflicting_known_groups_are_mixed_even_without_unknown(self):
|
||||
style={"layers":[{"id":"original-layer","source":"A","source-layer":"shared"}]}
|
||||
mapping={"assignments":[assignment("A",0,"shared","LAYER_ONLY","marks"),
|
||||
assignment("B",0,"shared","VISUAL_OBJECT_MATCH","fishery")]}
|
||||
out=audit.audit_isolation(style,mapping,2)
|
||||
self.assertEqual(out["layerCategoryCounts"],{"MIXED_OR_RESIDUAL":1})
|
||||
|
||||
def test_missing_catalog_coverage_and_invalid_binding_fail_closed(self):
|
||||
style={"layers":[{"id":"original-layer","source":"A","source-layer":"shared"}]}
|
||||
mapping={"assignments":[assignment("A",0,"shared","LAYER_ONLY","marks")]}
|
||||
with self.assertRaisesRegex(ValueError,"没有覆盖完整"):
|
||||
audit.audit_isolation(style,mapping,2)
|
||||
mapping["assignments"][0]["renderEvidence"]["components"][0]["styleLayerId"]="wrong"
|
||||
with self.assertRaisesRegex(ValueError,"mismatch"):
|
||||
audit.audit_isolation(style,mapping,1)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user