@@ -537,3 +537,85 @@ def test_script_flow_with_hello_fixture(hello_script, fixtures_dir):
537537 assert ":::fileio" in result
538538 assert ":::decision" in result
539539 assert "subgraph" in result # hello.py has functions
540+
541+
542+ # --- business mode ---
543+
544+
545+ def test_step_node_business_uses_translation ():
546+ """business=True produces translated label instead of raw description."""
547+ svc = Service (name = "Google Sheets" , library = "gspread" )
548+ step = Step (line_number = 10 , type = "api_call" , description = "gspread.authorize()" , service = svc )
549+ result = _step_node (step , "test" , business = True )
550+ assert "Authenticates with Google Sheets" in result
551+ # Should NOT have the technical prefix
552+ assert "API:" not in result
553+
554+
555+ def test_step_node_business_default_false ():
556+ """Default business=False still produces technical output."""
557+ step = Step (line_number = 10 , type = "api_call" , description = "requests.get()" )
558+ result_default = _step_node (step , "test" )
559+ result_explicit = _step_node (step , "test" , business = False )
560+ assert result_default == result_explicit
561+ assert "API: requests.get()" in result_default
562+
563+
564+ def test_script_flow_business_drops_parens ():
565+ """business=True subgraph labels drop the () suffix."""
566+ steps = [
567+ Step (line_number = 1 , type = "api_call" , description = "requests.get()" , function_name = "fetch" ),
568+ Step (line_number = 2 , type = "output" , description = "print()" , function_name = "fetch" ),
569+ ]
570+ script = AnalyzedScript (path = "test.py" , steps = steps )
571+ result = script_flow (script , business = True )
572+ # Business: "fetch" not "fetch()"
573+ assert '"fetch"' in result
574+ assert '"fetch()"' not in result
575+
576+
577+ def test_script_flow_technical_keeps_parens ():
578+ """Default technical mode keeps () on subgraph labels."""
579+ steps = [
580+ Step (line_number = 1 , type = "api_call" , description = "requests.get()" , function_name = "fetch" ),
581+ ]
582+ script = AnalyzedScript (path = "test.py" , steps = steps )
583+ result = script_flow (script , business = False )
584+ assert '"fetch()"' in result
585+
586+
587+ def test_compact_node_business_labels ():
588+ """business=True uses BUSINESS_LABELS in compact summary and drops ()."""
589+ steps = [
590+ Step (line_number = i , type = "file_io" , description = f"op{ i } " )
591+ for i in range (3 )
592+ ]
593+ result = _compact_function_node ("save_data" , steps , "test" , business = True )
594+ assert "Read/Write File" in result # BUSINESS_LABELS["file_io"]
595+ assert "File I/O" not in result # _TYPE_LABELS["file_io"]
596+ assert "save_data" in result
597+ assert "save_data()" not in result # no parens in business mode
598+
599+
600+ def test_compact_node_technical_labels ():
601+ """Default technical mode uses _TYPE_LABELS and keeps ()."""
602+ steps = [
603+ Step (line_number = i , type = "file_io" , description = f"op{ i } " )
604+ for i in range (3 )
605+ ]
606+ result = _compact_function_node ("save_data" , steps , "test" )
607+ assert "File I/O" in result
608+ assert "save_data()" in result
609+
610+
611+ def test_project_graph_business_connections ():
612+ """business=True translates connection edge labels."""
613+ scripts = [AnalyzedScript (path = "a.py" ), AnalyzedScript (path = "b.py" )]
614+ connections = [
615+ ScriptConnection (source = "a.py" , target = "b.py" , type = "import" , detail = "" ),
616+ ]
617+ project = AnalyzedProject (path = "/tmp" , scripts = scripts , connections = connections )
618+ result_biz = project_graph (project , business = True )
619+ result_tech = project_graph (project , business = False )
620+ assert '"uses"' in result_biz
621+ assert '"import"' in result_tech
0 commit comments