@@ -67,6 +67,7 @@ def test_schemeedit(self):
6767 self .assertFalse (w .isModified ())
6868
6969 scheme = Scheme ()
70+ root = scheme .root ()
7071 w .setScheme (scheme )
7172
7273 self .assertIs (w .scheme (), scheme )
@@ -94,15 +95,15 @@ def test_schemeedit(self):
9495 w .addNode (node )
9596
9697 self .assertSequenceEqual (node_list , [node ])
97- self .assertSequenceEqual (scheme .nodes , node_list )
98+ self .assertSequenceEqual (root .nodes () , node_list )
9899
99100 self .assertTrue (w .isModified ())
100101
101102 stack = w .undoStack ()
102103 stack .undo ()
103104
104105 self .assertSequenceEqual (node_list , [])
105- self .assertSequenceEqual (scheme .nodes , node_list )
106+ self .assertSequenceEqual (root .nodes () , node_list )
106107 self .assertTrue (not w .isModified ())
107108
108109 stack .redo ()
@@ -111,7 +112,7 @@ def test_schemeedit(self):
111112 w .addNode (node1 )
112113
113114 self .assertSequenceEqual (node_list , [node , node1 ])
114- self .assertSequenceEqual (scheme .nodes , node_list )
115+ self .assertSequenceEqual (root .nodes () , node_list )
115116 self .assertTrue (w .isModified ())
116117
117118 link = SchemeLink (node , "value" , node1 , "value" )
@@ -243,14 +244,15 @@ def test_arrow_annotation_action(self):
243244 w = self .w
244245 workflow = w .scheme ()
245246 workflow .clear ()
247+ root = workflow .root ()
246248 view = w .view ()
247249 actions = w .toolbarActions ()
248250 action_by_name (actions , "new-arrow-action" ).trigger ()
249251 QTest .mousePress (view .viewport (), Qt .LeftButton , pos = QPoint (50 , 50 ))
250252 mouseMove (view .viewport (), Qt .LeftButton , pos = QPoint (100 , 100 ))
251253 QTest .mouseRelease (view .viewport (), Qt .LeftButton , pos = QPoint (100 , 100 ))
252- self .assertEqual (len (workflow .annotations ), 1 )
253- self .assertIsInstance (workflow .annotations [0 ], SchemeArrowAnnotation )
254+ self .assertEqual (len (root .annotations () ), 1 )
255+ self .assertIsInstance (root .annotations () [0 ], SchemeArrowAnnotation )
254256
255257 def test_arrow_annotation_action_cancel (self ):
256258 w = self .w
@@ -269,7 +271,7 @@ def test_arrow_annotation_action_cancel(self):
269271 mouseMove (view .viewport (), Qt .LeftButton , pos = QPoint (100 , 100 ))
270272 QTest .keyClick (view .viewport (), Qt .Key_Escape )
271273 self .assertFalse (action .isChecked ())
272- self .assertEqual (workflow .annotations , [])
274+ self .assertEqual (workflow .root (). annotations () , [])
273275
274276 def test_text_annotation_action (self ):
275277 w = self .w
@@ -284,8 +286,8 @@ def test_text_annotation_action(self):
284286 # need to steal focus from the item for it to be commited.
285287 w .scene ().setFocusItem (None )
286288
287- self .assertEqual (len (workflow .annotations ), 1 )
288- self .assertIsInstance (workflow .annotations [0 ], SchemeTextAnnotation )
289+ self .assertEqual (len (workflow .root (). annotations () ), 1 )
290+ self .assertIsInstance (workflow .root (). annotations () [0 ], SchemeTextAnnotation )
289291
290292 def test_text_annotation_action_cancel (self ):
291293 w = self .w
@@ -305,7 +307,7 @@ def test_text_annotation_action_cancel(self):
305307 QTest .keyClick (view .viewport (), Qt .Key_Escape )
306308 self .assertFalse (action .isChecked ())
307309 w .scene ().setFocusItem (None )
308- self .assertEqual (workflow .annotations , [])
310+ self .assertEqual (workflow .root (). annotations () , [])
309311
310312 def test_path (self ):
311313 w = self .w
@@ -330,16 +332,14 @@ def test_select(self):
330332 w = self .w
331333 self .setup_test_workflow (w .scheme ())
332334 w .selectAll ()
333- self .assertSequenceEqual (
334- w .selectedNodes (), w .scheme ().nodes )
335- self .assertSequenceEqual (
336- w .selectedAnnotations (), w .scheme ().annotations )
337- self .assertSequenceEqual (
338- w .selectedLinks (), w .scheme ().links )
335+ root = w .root ()
336+ self .assertSequenceEqual (w .selectedNodes (), root .nodes ())
337+ self .assertSequenceEqual (w .selectedAnnotations (), root .annotations ())
338+ self .assertSequenceEqual (w .selectedLinks (), root .links ())
339339 w .removeSelected ()
340- self .assertEqual (w . scheme (). nodes , [])
341- self .assertEqual (w . scheme (). annotations , [])
342- self .assertEqual (w . scheme (). links , [])
340+ self .assertEqual (root . nodes () , [])
341+ self .assertEqual (root . annotations () , [])
342+ self .assertEqual (root . links () , [])
343343
344344 def test_select_remove_link (self ):
345345 def link_curve (link : SchemeLink ) -> QPainterPath :
@@ -348,16 +348,17 @@ def link_curve(link: SchemeLink) -> QPainterPath:
348348 return item .mapToScene (path )
349349 w = self .w
350350 workflow = self .setup_test_workflow (w .scheme ())
351+ root = workflow .root ()
351352 w .alignToGrid ()
352353 scene , view = w .scene (), w .view ()
353- link = workflow .links [0 ]
354+ link = root .links () [0 ]
354355 path = link_curve (link )
355356 p = path .pointAtPercent (0.5 )
356357 QTest .mouseClick (view .viewport (), Qt .LeftButton , pos = view .mapFromScene (p ))
357358 self .assertSequenceEqual (w .selectedLinks (), [link ])
358359 w .removeSelected ()
359360 self .assertSequenceEqual (w .selectedLinks (), [])
360- self .assertTrue (link not in workflow .links )
361+ self .assertTrue (link not in root .links () )
361362
362363 def test_open_selected (self ):
363364 w = self .w
@@ -368,12 +369,13 @@ def test_open_selected(self):
368369 def test_insert_node_on_link (self ):
369370 w = self .w
370371 workflow = self .setup_test_workflow (w .scheme ())
372+ root = workflow .root ()
371373 neg = SchemeNode (self .reg .widget ("negate" ))
372- target = workflow .links [0 ]
374+ target = root .links () [0 ]
373375 spyrem = QSignalSpy (workflow .link_removed )
374376 spyadd = QSignalSpy (workflow .link_added )
375377 w .insertNode (neg , target )
376- self .assertEqual (workflow .nodes [- 1 ], neg )
378+ self .assertEqual (root .nodes () [- 1 ], neg )
377379
378380 self .assertSequenceEqual (list (spyrem ), [[target , workflow .root ()]])
379381 self .assertEqual (len (spyadd ), 2 )
@@ -387,33 +389,36 @@ def test_align_to_grid(self):
387389 def test_activate_node (self ):
388390 w = self .w
389391 workflow = self .setup_test_workflow ()
392+ root = workflow .root ()
390393 w .setScheme (workflow )
391394
392395 view , scene = w .view (), w .scene ()
393- item = scene .item_for_node (workflow .nodes [0 ]) # type: QGraphicsWidget
396+ item = scene .item_for_node (root .nodes () [0 ]) # type: QGraphicsWidget
394397 item .setSelected (True )
395398 item .setFocus (Qt .OtherFocusReason )
396- self .assertIs (w .focusNode (), workflow .nodes [0 ])
399+ self .assertIs (w .focusNode (), root .nodes () [0 ])
397400 item .activated .emit ()
398401
399402 def test_duplicate (self ):
400403 w = self .w
401404 workflow = self .setup_test_workflow ()
405+ root = workflow .root ()
402406 w .setScheme (workflow )
403407 w .selectAll ()
404- nnodes , nlinks = len (workflow .nodes ) , len (workflow .links )
408+ nnodes , nlinks = len (root .nodes ()) , len (root .links () )
405409 a = action_by_name (w .actions (), "duplicate-action" )
406410 a .trigger ()
407- self .assertEqual (len (workflow .nodes ), 2 * nnodes )
408- self .assertEqual (len (workflow .links ), 2 * nlinks )
411+ self .assertEqual (len (root .nodes () ), 2 * nnodes )
412+ self .assertEqual (len (root .links () ), 2 * nlinks )
409413
410414 def test_copy_paste (self ):
411415 w = self .w
412416 workflow = self .setup_test_workflow ()
417+ root = workflow .root ()
413418 w .setRegistry (self .reg )
414419 w .setScheme (workflow )
415420 w .selectAll ()
416- nnodes , nlinks = len (workflow .nodes ) , len (workflow .links )
421+ nnodes , nlinks = len (root .nodes ()) , len (root .links () )
417422 ca = action_by_name (w .actions (), "copy-action" )
418423 cp = action_by_name (w .actions (), "paste-action" )
419424 cb = QApplication .clipboard ()
@@ -423,8 +428,8 @@ def test_copy_paste(self):
423428 self .assertTrue (spy .wait ())
424429 self .assertEqual (len (spy ), 1 )
425430 cp .trigger ()
426- self .assertEqual (len (workflow .nodes ), 2 * nnodes )
427- self .assertEqual (len (workflow .links ), 2 * nlinks )
431+ self .assertEqual (len (root .nodes () ), 2 * nnodes )
432+ self .assertEqual (len (root .links () ), 2 * nlinks )
428433
429434 w1 = SchemeEditWidget ()
430435 w1 .setRegistry (self .reg )
@@ -433,34 +438,36 @@ def test_copy_paste(self):
433438 self .assertTrue (cp .isEnabled ())
434439 cp .trigger ()
435440 wf1 = w1 .scheme ()
436- self .assertEqual (len (wf1 .nodes ), nnodes )
437- self .assertEqual (len (wf1 .links ), nlinks )
441+ root1 = wf1 .root ()
442+ self .assertEqual (len (root1 .nodes ()), nnodes )
443+ self .assertEqual (len (root1 .links ()), nlinks )
438444
439445 def test_redo_remove_preserves_order (self ):
440446 w = self .w
441447 workflow = self .setup_test_workflow ()
448+ root = workflow .root ()
442449 w .setRegistry (self .reg )
443450 w .setScheme (workflow )
444451 undo = w .undoStack ()
445- links = workflow .links
446- nodes = workflow .nodes
447- annotations = workflow .annotations
452+ links = root .links ()
453+ nodes = root .nodes ()
454+ annotations = root .annotations ()
448455 assert len (links ) > 2
449456 w .removeLink (links [1 ])
450- self .assertSequenceEqual (links [:1 ] + links [2 :], workflow .links )
457+ self .assertSequenceEqual (links [:1 ] + links [2 :], root .links () )
451458 undo .undo ()
452- self .assertSequenceEqual (links , workflow .links )
459+ self .assertSequenceEqual (links , root .links () )
453460 # find add node that has multiple in/out links
454- node = findf (workflow .nodes , lambda n : n .title == "add" )
461+ node = findf (root .nodes () , lambda n : n .title == "add" )
455462 w .removeNode (node )
456463 undo .undo ()
457- self .assertSequenceEqual (links , workflow .links )
458- self .assertSequenceEqual (nodes , workflow .nodes )
464+ self .assertSequenceEqual (links , root .links () )
465+ self .assertSequenceEqual (nodes , root .nodes () )
459466
460467 w .removeAnnotation (annotations [0 ])
461- self .assertSequenceEqual (annotations [1 :], workflow .annotations )
468+ self .assertSequenceEqual (annotations [1 :], root .annotations () )
462469 undo .undo ()
463- self .assertSequenceEqual (annotations , workflow .annotations )
470+ self .assertSequenceEqual (annotations , root .annotations () )
464471
465472 def test_create_macro (self ):
466473 w = self .w
@@ -495,9 +502,10 @@ def test_expand_macro(self):
495502 def test_window_groups (self ):
496503 w = self .w
497504 workflow = self .setup_test_workflow ()
505+ nodes = workflow .root ().nodes ()
498506 workflow .set_window_group_presets ([
499- Scheme .WindowGroup ("G1" , False , [(workflow . nodes [0 ], b'\xff \x00 ' )]),
500- Scheme .WindowGroup ("G2" , True , [(workflow . nodes [0 ], b'\xff \x00 ' )]),
507+ Scheme .WindowGroup ("G1" , False , [(nodes [0 ], b'\xff \x00 ' )]),
508+ Scheme .WindowGroup ("G2" , True , [(nodes [0 ], b'\xff \x00 ' )]),
501509 ])
502510 manager = TestingWidgetManager ()
503511 workflow .widget_manager = manager
@@ -536,6 +544,7 @@ def test_drop_event(self):
536544 w = self .w
537545 w .setRegistry (self .reg )
538546 workflow = w .scheme ()
547+ root = workflow .root ()
539548 desc = self .reg .widget ("one" )
540549 viewport = w .view ().viewport ()
541550 mime = QMimeData ()
@@ -546,12 +555,12 @@ def test_drop_event(self):
546555
547556 self .assertTrue (dragDrop (viewport , mime , QPoint (10 , 10 )))
548557
549- self .assertEqual (len (workflow .nodes ), 1 )
550- self .assertEqual (workflow .nodes [0 ].description , desc )
558+ self .assertEqual (len (root .nodes () ), 1 )
559+ self .assertEqual (root .nodes () [0 ].description , desc )
551560
552561 dragEnterLeave (viewport , mime )
553562
554- self .assertEqual (len (workflow .nodes ), 1 )
563+ self .assertEqual (len (root .nodes () ), 1 )
555564
556565 def test_drag_drop (self ):
557566 w = self .w
@@ -601,6 +610,7 @@ def test_plugin_drag_drop(self):
601610 w .setRegistry (self .reg )
602611 w .setDropHandlers ([handler ])
603612 workflow = w .scheme ()
613+ root = workflow .root ()
604614 viewport = w .view ().viewport ()
605615 # Test empty handler
606616 mime = QMimeData ()
@@ -617,9 +627,9 @@ def test_plugin_drag_drop(self):
617627 dragDrop (viewport , mime , QPoint (10 , 10 ))
618628
619629 self .assertIsNone (w ._userInteractionHandler ())
620- self .assertEqual (len (workflow .nodes ), 1 )
621- self .assertEqual (workflow .nodes [0 ].description .name , "one" )
622- self .assertEqual (workflow .nodes [0 ].properties , {"a" : "from drop" })
630+ self .assertEqual (len (root .nodes () ), 1 )
631+ self .assertEqual (root .nodes () [0 ].description .name , "one" )
632+ self .assertEqual (root .nodes () [0 ].properties , {"a" : "from drop" })
623633
624634 workflow .clear ()
625635
@@ -635,9 +645,9 @@ def exec(self, *args):
635645 with mock .patch .object (QMenu , "exec" , exec ):
636646 dragDrop (viewport , mime , QPoint (10 , 10 ))
637647
638- self .assertEqual (len (workflow .nodes ), 1 )
639- self .assertEqual (workflow .nodes [0 ].description .name , "one" )
640- self .assertEqual (workflow .nodes [0 ].properties , {"a" : "from drop" })
648+ self .assertEqual (len (root .nodes () ), 1 )
649+ self .assertEqual (root .nodes () [0 ].description .name , "one" )
650+ self .assertEqual (root .nodes () [0 ].properties , {"a" : "from drop" })
641651
642652 def test_activate_drop_node (self ):
643653 class NodeFromMimeData (TestNodeFromMimeData ):
0 commit comments