11from codeanalyzer .schema .l2_callees import backfill_callees
2+ from codeanalyzer .schema .call_graph_ids import reidentify_call_graph
23from codeanalyzer .schema .py_schema import (
3- PyApplication , PyModule , PyCallable , PyCallsite , BodyNode ,
4+ PyApplication , PyModule , PyCallable , PyCallsite , BodyNode , PyCallEdge ,
45)
56
67def _app_with_one_call (callee_sig ):
@@ -25,3 +26,18 @@ def test_unresolved_callsite_leaves_callee_absent():
2526 app , fn = _app_with_one_call (None )
2627 backfill_callees (app , {})
2728 assert fn .body ["2:4" ].callee is None
29+
30+ def test_call_graph_endpoints_reidentified ():
31+ edge = PyCallEdge (source = "m.f" , target = "m.g" )
32+ app = PyApplication (symbol_table = {}, call_graph = [edge ])
33+ reidentify_call_graph (app , {"m.f" : "can://python/app/m.py/f()" ,
34+ "m.g" : "can://python/app/m.py/g()" })
35+ assert app .call_graph [0 ].source == "can://python/app/m.py/f()"
36+ assert app .call_graph [0 ].target == "can://python/app/m.py/g()"
37+
38+ def test_call_graph_external_target_unchanged ():
39+ edge = PyCallEdge (source = "m.f" , target = "requests.get" )
40+ app = PyApplication (symbol_table = {}, call_graph = [edge ])
41+ reidentify_call_graph (app , {"m.f" : "can://python/app/m.py/f()" })
42+ assert app .call_graph [0 ].source == "can://python/app/m.py/f()"
43+ assert app .call_graph [0 ].target == "requests.get"
0 commit comments