@@ -76,8 +76,14 @@ def test_parallel_relation_deletion_is_not_label_modification(self):
7676
7777class TestRender (unittest .TestCase ):
7878 def _diff (self ):
79- base = {"components" : [comp ("A" ), comp ("B" ), comp ("Gone" )], "components_relations" : [rel ("A" , "B" ), rel ("A" , "Gone" )]}
80- head = {"components" : [comp ("A" , {"x.py" : ["f" ]}), comp ("B" ), comp ("New" )], "components_relations" : [rel ("A" , "B" ), rel ("A" , "New" )]}
79+ base = {
80+ "components" : [comp ("A" ), comp ("B" ), comp ("Gone" )],
81+ "components_relations" : [rel ("A" , "B" ), rel ("A" , "Gone" )],
82+ }
83+ head = {
84+ "components" : [comp ("A" , {"x.py" : ["f" ]}), comp ("B" ), comp ("New" )],
85+ "components_relations" : [rel ("A" , "B" ), rel ("A" , "New" )],
86+ }
8187 return dm .build_diff (base , head )
8288
8389 def test_flat_default_has_no_subgraphs (self ):
@@ -88,8 +94,14 @@ def test_flat_default_has_no_subgraphs(self):
8894 self .assertTrue (linkstyle_indices_in_range (text ))
8995
9096 def test_nested_subgraphs_balanced_and_valid (self ):
91- base = {"components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" )])], "components_relations" : []}
92- head = {"components" : [comp ("P" , subs = [comp ("c1" ), comp ("c3" )], subrels = [rel ("c1" , "c3" )])], "components_relations" : []}
97+ base = {
98+ "components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" )])],
99+ "components_relations" : [],
100+ }
101+ head = {
102+ "components" : [comp ("P" , subs = [comp ("c1" ), comp ("c3" )], subrels = [rel ("c1" , "c3" )])],
103+ "components_relations" : [],
104+ }
93105 text , _ = dm .render_mermaid (dm .build_diff (base , head ), render_depth = 2 )
94106 sg = sum (1 for line in text .splitlines () if line .strip ().startswith ("subgraph " ))
95107 en = sum (1 for line in text .splitlines () if line .strip () == "end" )
@@ -164,16 +176,25 @@ def test_nested_method_change_highlights_collapsed_parent(self):
164176 self .assertIn ("class n_P modified;" , text )
165177
166178 def test_nested_relation_change_highlights_collapsed_parent (self ):
167- base = {"components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" , "uses" )])], "components_relations" : []}
168- head = {"components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" , "calls" )])], "components_relations" : []}
179+ base = {
180+ "components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" , "uses" )])],
181+ "components_relations" : [],
182+ }
183+ head = {
184+ "components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [rel ("c1" , "c2" , "calls" )])],
185+ "components_relations" : [],
186+ }
169187 text , meta = dm .render_mermaid (dm .build_diff (base , head ), render_depth = 1 )
170188 self .assertEqual (meta ["n_changed" ], 0 )
171189 self .assertTrue (meta ["changed" ])
172190 self .assertIn ("class n_P modified;" , text )
173191
174192 def test_changed_only_keeps_nested_change (self ):
175193 base = {"components" : [comp ("P" , subs = [comp ("c1" ), comp ("c2" )], subrels = [])], "components_relations" : []}
176- head = {"components" : [comp ("P" , subs = [comp ("c1" , {"x.py" : ["f" ]}), comp ("c2" )], subrels = [])], "components_relations" : []}
194+ head = {
195+ "components" : [comp ("P" , subs = [comp ("c1" , {"x.py" : ["f" ]}), comp ("c2" )], subrels = [])],
196+ "components_relations" : [],
197+ }
177198 text , meta = dm .render_mermaid (dm .build_diff (base , head ), render_depth = 2 , changed_only = True )
178199 self .assertIsNotNone (text )
179200 self .assertTrue (meta ["changed" ])
@@ -183,8 +204,14 @@ def test_changed_only_keeps_nested_change(self):
183204 self .assertNotIn ('n_c2["c2"]' , text )
184205
185206 def test_changed_only_prunes_unchanged_children_of_modified_parent (self ):
186- base = {"components" : [comp ("P" , {"p.py" : ["old" ]}, subs = [comp ("c1" ), comp ("c2" )], subrels = [])], "components_relations" : []}
187- head = {"components" : [comp ("P" , {"p.py" : ["old" , "new" ]}, subs = [comp ("c1" ), comp ("c2" )], subrels = [])], "components_relations" : []}
207+ base = {
208+ "components" : [comp ("P" , {"p.py" : ["old" ]}, subs = [comp ("c1" ), comp ("c2" )], subrels = [])],
209+ "components_relations" : [],
210+ }
211+ head = {
212+ "components" : [comp ("P" , {"p.py" : ["old" , "new" ]}, subs = [comp ("c1" ), comp ("c2" )], subrels = [])],
213+ "components_relations" : [],
214+ }
188215 text , meta = dm .render_mermaid (dm .build_diff (base , head ), render_depth = 2 , changed_only = True )
189216 self .assertIsNotNone (text )
190217 self .assertTrue (meta ["changed" ])
0 commit comments