afv-library/skills/explaining-batch-data-transform/tests/fixtures/minimal.json

58 lines
1.7 KiB
JSON
Raw Normal View History

test(bdt): unit tests + adversarial fixtures @W-22196528@ Adds the full test suite for bdt_analyze.py: 92 unit tests backed by 9 JSON fixtures (4 normative + 5 adversarial). All tests stdlib-only, runnable via `python3 -m unittest tests.test_bdt_analyze`. tests/test_bdt_analyze.py coverage: DAG primitives: - roots() / sinks() / topo_order() on minimal + branching graphs. - upstream() / downstream() reachability correctness. - Cycle tolerance: topo_order + traversals do not infinite-loop or raise when the graph contains a cycle; cycle is reported via broken_references-adjacent signals. - Broken-reference tolerance: nodes referencing non-existent upstreams are handled gracefully; broken_references() enumerates them. CLI subcommands (happy-path + error-path for each): - summary, sources, outputs, stages, nodes, node, lineage, field-trace, formula, definitions — each exercised in both human-readable and --json modes. - Exit-code discipline: unknown node -> exit 2, malformed input -> exit 3, success -> exit 0. - Unknown-action graceful degradation: nodes whose action isn't in the catalog still appear in summary/nodes output with a generic label rather than crashing. - Output size budgets: default-mode outputs are asserted to stay within configured character caps. Field discovery: - fields_produced() / fields_consumed() / _scrape_field_refs() heuristics tested against both clean and noisy formula bodies. - TestFieldTraceFocus — narrowing tests preventing false-positive substring hits in formula text. Dual-shape input: - TestInputShapeDetection — editor export vs. Connect API single-definition auto-detection. - TestMultiDefinition — Connect API multi-definition payload: definitions subcommand, --definition N routing, out-of-range index error handling. Fixtures (tests/fixtures/): - minimal.json — smallest valid editor-export BDT. - window_and_aggregate.json — window + aggregate composition. - api_input_single.json — Connect API single-definition payload. - api_input_multi.json — Connect API multi-definition payload. Adversarial fixtures (tests/fixtures/adversarial/): - cycle.json — graph with a cycle; parser must not hang. - broken_ref.json — node referencing a non-existent upstream. - unknown_action.json — node with an action not in the catalog. - no_ui.json — BDT missing the UI layer entirely. - empty_nodes.json — valid envelope but zero nodes. Suite status: Ran 92 tests, OK. @W-22196528@
2026-04-24 01:16:09 +08:00
{
"version": "66.0",
"nodes": {
"LOAD_DATASET0": {
"action": "load",
"sources": [],
"parameters": {
"dataset": {"name": "ssot__Account__dlm", "type": "dataModelObject"},
"fields": ["ssot__Id__c", "ssot__Name__c"],
"sampleDetails": {"type": "TopN", "sortBy": []}
}
},
"FORMULA0": {
"action": "formula",
"sources": ["LOAD_DATASET0"],
"parameters": {
"expressionType": "SQL",
"fields": [
{
"name": "AccountNameUpper__c",
"label": "Account Name Upper",
"formulaExpression": "upper(ssot__Name__c)",
"type": "TEXT",
"businessType": "Text",
"precision": 255,
"defaultValue": ""
}
]
}
},
"OUTPUT0": {
"action": "outputD360",
"sources": ["FORMULA0"],
"parameters": {
"name": "Account_Upper__dlm",
"type": "dataModelObject",
"writeMode": "OVERWRITE",
"fieldsMappings": [
{"sourceField": "ssot__Id__c", "targetField": "ssot__Id__c"},
{"sourceField": "AccountNameUpper__c", "targetField": "Name_Upper__c"}
]
}
}
},
"ui": {
"nodes": {
"LOAD_DATASET0": {"label": "Account", "type": "LOAD_DATASET", "top": 100, "left": 100},
"FORMULA0": {"label": "Uppercase Name", "type": "FORMULA", "top": 100, "left": 240},
"OUTPUT0": {"label": "Account Upper", "type": "OUTPUT", "top": 100, "left": 380}
},
"connectors": [
{"source": "LOAD_DATASET0", "target": "FORMULA0"},
{"source": "FORMULA0", "target": "OUTPUT0"}
],
"hiddenColumns": []
}
}