@@ -530,6 +530,18 @@ def test_set_simple_dependency_set(self):
530530
531531 self .assertEqual (t ['depends' ], set ([dependency ]))
532532
533+ def test_set_simple_dependency_lazyuuidtaskset (self ):
534+ # Adds only one dependency as a LazyUUIDTaskSet to task with no dependencies
535+ t = Task (self .tw , description = 'test task' )
536+ dependency = Task (self .tw , description = 'needs to be done first' )
537+
538+ t .save ()
539+ dependency .save ()
540+
541+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]])
542+
543+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]]))
544+
533545 def test_set_complex_dependency_set (self ):
534546 # Adds two dependencies to task with no dependencies
535547 t = Task (self .tw , description = 'test task' )
@@ -544,6 +556,20 @@ def test_set_complex_dependency_set(self):
544556
545557 self .assertEqual (t ['depends' ], set ([dependency1 , dependency2 ]))
546558
559+ def test_set_complex_dependency_lazyuuidtaskset (self ):
560+ # Adds two dependencies as a LazyUUIDTaskSet to task with no dependencies
561+ t = Task (self .tw , description = 'test task' )
562+ dependency1 = Task (self .tw , description = 'needs to be done first' )
563+ dependency2 = Task (self .tw , description = 'needs to be done second' )
564+
565+ t .save ()
566+ dependency1 .save ()
567+ dependency2 .save ()
568+
569+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ], dependency2 ['uuid' ]])
570+
571+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ], dependency2 ['uuid' ]]))
572+
547573 def test_remove_from_dependency_set (self ):
548574 # Removes dependency from task with two dependencies
549575 t = Task (self .tw , description = 'test task' )
@@ -561,6 +587,23 @@ def test_remove_from_dependency_set(self):
561587
562588 self .assertEqual (t ['depends' ], set ([dependency1 ]))
563589
590+ def test_remove_from_dependency_lazyuuidtaskset (self ):
591+ # Removes dependency from task with two dependencies as LazyUUIDTaskSet
592+ t = Task (self .tw , description = 'test task' )
593+ dependency1 = Task (self .tw , description = 'needs to be done first' )
594+ dependency2 = Task (self .tw , description = 'needs to be done second' )
595+
596+ dependency1 .save ()
597+ dependency2 .save ()
598+
599+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ], dependency2 ['uuid' ]])
600+ t .save ()
601+
602+ t ['depends' ].remove (dependency2 )
603+ t .save ()
604+
605+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ]]))
606+
564607 def test_add_to_dependency_set (self ):
565608 # Adds dependency to task with one dependencies
566609 t = Task (self .tw , description = 'test task' )
@@ -578,8 +621,42 @@ def test_add_to_dependency_set(self):
578621
579622 self .assertEqual (t ['depends' ], set ([dependency1 , dependency2 ]))
580623
624+ def test_add_to_dependency_lazyuuidtaskset (self ):
625+ # Adds dependency to task with one dependencies as LazyUUIDTaskSet
626+ t = Task (self .tw , description = 'test task' )
627+ dependency1 = Task (self .tw , description = 'needs to be done first' )
628+ dependency2 = Task (self .tw , description = 'needs to be done second' )
629+
630+ dependency1 .save ()
631+ dependency2 .save ()
632+
633+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ]])
634+ t .save ()
635+
636+ t ['depends' ].add (dependency2 )
637+ t .save ()
638+
639+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ], dependency2 ['uuid' ]]))
640+
641+ def test_add_lazyuuidtaskset_to_dependency_lazyuuidtaskset (self ):
642+ # Adds dependency as LazyUUIDTaskSet to task with one dependencies as LazyUUIDTaskSet
643+ t = Task (self .tw , description = 'test task' )
644+ dependency1 = Task (self .tw , description = 'needs to be done first' )
645+ dependency2 = Task (self .tw , description = 'needs to be done second' )
646+
647+ dependency1 .save ()
648+ dependency2 .save ()
649+
650+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ]])
651+ t .save ()
652+
653+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency2 ['uuid' ]]).union (t ['depends' ])
654+ t .save ()
655+
656+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency1 ['uuid' ], dependency2 ['uuid' ]]))
657+
581658 def test_add_to_empty_dependency_set (self ):
582- # Adds dependency to task with one dependencies
659+ # Adds dependency to task with no dependencies
583660 t = Task (self .tw , description = 'test task' )
584661 dependency = Task (self .tw , description = 'needs to be done first' )
585662
@@ -590,6 +667,18 @@ def test_add_to_empty_dependency_set(self):
590667
591668 self .assertEqual (t ['depends' ], set ([dependency ]))
592669
670+ def test_add_to_empty_dependency_lazyuuidtaskset (self ):
671+ # Adds dependency as LazyUUIDTaskSet to task with no dependencies
672+ t = Task (self .tw , description = 'test task' )
673+ dependency = Task (self .tw , description = 'needs to be done first' )
674+
675+ dependency .save ()
676+
677+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]])
678+ t .save ()
679+
680+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]]))
681+
593682 def test_simple_dependency_set_save_repeatedly (self ):
594683 # Adds only one dependency to task with no dependencies
595684 t = Task (self .tw , description = 'test task' )
@@ -612,6 +701,40 @@ def test_simple_dependency_set_save_repeatedly(self):
612701
613702 self .assertEqual (t ['depends' ], set ([dependency ]))
614703
704+ def test_simple_dependency_lazyuuidtaskset_save_repeatedly (self ):
705+ # Adds only one dependency as LazyUUIDTaskSet to task with no dependencies
706+ t = Task (self .tw , description = 'test task' )
707+ dependency = Task (self .tw , description = 'needs to be done first' )
708+ dependency .save ()
709+
710+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]])
711+ t .save ()
712+
713+ # We taint the task, but keep depends intact
714+ t ['description' ] = 'test task modified'
715+ t .save ()
716+
717+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]]))
718+
719+ # We taint the task, but assign the same set to the depends
720+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]])
721+ t ['description' ] = 'test task modified again'
722+ t .save ()
723+
724+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]]))
725+
726+ def test_simple_dependency_lazyuuidtaskset_save_before_repeatedly (self ):
727+ # Adds only one dependency as LazyUUIDTaskSet to a saved task with no dependencies
728+ t = Task (self .tw , description = 'test task' )
729+ dependency = Task (self .tw , description = 'needs to be done first' )
730+ dependency .save ()
731+ t .save ()
732+
733+ t ['depends' ] = LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]])
734+ t .save ()
735+
736+ self .assertEqual (t ['depends' ], LazyUUIDTaskSet (self .tw , [dependency ['uuid' ]]))
737+
615738 def test_compare_different_tasks (self ):
616739 # Negative: compare two different tasks
617740 t1 = Task (self .tw , description = 'test task' )
0 commit comments