mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-08-09 00:42:46 +08:00
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@
62 lines
1.9 KiB
JSON
62 lines
1.9 KiB
JSON
{
|
|
"version": "66.0",
|
|
"nodes": {
|
|
"LOAD_ORDERS": {
|
|
"action": "load",
|
|
"sources": [],
|
|
"parameters": {
|
|
"dataset": {"name": "ssot__SalesOrder__dlm", "type": "dataModelObject"},
|
|
"fields": ["ssot__Id__c", "ssot__AccountId__c", "ssot__CreatedDate__c", "ssot__GrandTotalAmount__c"],
|
|
"sampleDetails": {"type": "TopN", "sortBy": []}
|
|
}
|
|
},
|
|
"RANK_ORDERS": {
|
|
"action": "computeRelative",
|
|
"sources": ["LOAD_ORDERS"],
|
|
"parameters": {
|
|
"partitionBy": ["ssot__AccountId__c"],
|
|
"orderBy": [{"fieldName": "ssot__CreatedDate__c", "direction": "ASC"}],
|
|
"expressionType": "SQL",
|
|
"fields": [
|
|
{
|
|
"name": "OrderRank__c",
|
|
"label": "Order Rank",
|
|
"formulaExpression": "row_number()",
|
|
"type": "NUMBER",
|
|
"businessType": "Number",
|
|
"precision": 18,
|
|
"scale": 0,
|
|
"defaultValue": ""
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"AGG_BY_ACCOUNT": {
|
|
"action": "aggregate",
|
|
"sources": ["RANK_ORDERS"],
|
|
"parameters": {
|
|
"groupings": ["ssot__AccountId__c"],
|
|
"aggregations": [
|
|
{"action": "SUM", "name": "TotalAmount__c", "source": "ssot__GrandTotalAmount__c"},
|
|
{"action": "COUNT", "name": "OrderCount__c", "source": "ssot__Id__c"}
|
|
],
|
|
"nodeType": "STANDARD"
|
|
}
|
|
},
|
|
"OUTPUT_SUMMARY": {
|
|
"action": "outputD360",
|
|
"sources": ["AGG_BY_ACCOUNT"],
|
|
"parameters": {
|
|
"name": "Account_Summary__dlm",
|
|
"type": "dataModelObject",
|
|
"writeMode": "OVERWRITE",
|
|
"fieldsMappings": [
|
|
{"sourceField": "ssot__AccountId__c", "targetField": "AccountId__c"},
|
|
{"sourceField": "TotalAmount__c", "targetField": "TotalAmount__c"},
|
|
{"sourceField": "OrderCount__c", "targetField": "OrderCount__c"}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|