def test_root_handling(): """Test updating of item when a sequence get/lose the root. """ root = RootSequence() context = TestContext() root.context = context sequence1 = BaseSequence() sequence2 = BaseSequence() pulse = Pulse() sequence2.add_child_item(0, pulse) sequence1.add_child_item(0, sequence2) root.add_child_item(0, sequence1) assert pulse.root is root and sequence2.root is root assert sequence2.has_observers('_last_index') root.remove_child_item(0) assert pulse.root is None and sequence2.root is None assert not sequence2.has_observers('_last_index')
def test_root_handling(): """Test updating of item when a sequence get/lose the root. """ root = RootSequence() context = TestContext() root.context = context sequence1 = BaseSequence() sequence2 = BaseSequence() pulse = Pulse() sequence2.add_child_item(0, pulse) sequence1.add_child_item(0, sequence2) root.add_child_item(0, sequence1) assert pulse.root is root and sequence2.root is root assert sequence2.has_observers('_last_index') root.remove_child_item(0) assert pulse.root is None and sequence2.root is None assert not sequence2.has_observers('_last_index')
def test_sequence_indexing1(): """Test adding, moving, deleting pulse in a sequence. """ root = RootSequence() root.time_constrained = True root.sequence_duration = '1.0' context = TestContext() root.context = context pulse1 = Pulse() pulse2 = Pulse() pulse3 = Pulse() root.add_child_item(0, pulse1) assert pulse1.index == 1 assert pulse1.root is root assert (sorted(root.get_accessible_vars()) == (sorted(['sequence_end', '1_start', '1_stop', '1_duration']))) root.add_child_item(1, pulse2) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse2.root is root assert (sorted(root.get_accessible_vars()) == sorted(['sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration'])) root.move_child_item(0, 1) assert pulse1.index == 2 assert pulse2.index == 1 assert (sorted(root.get_accessible_vars()) == sorted(['sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration'])) root.move_child_item(0, 1) root.add_child_item(2, pulse3) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse3.index == 3 assert pulse3.root is root assert (sorted(root.get_accessible_vars()) == sorted(['sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration', '3_start', '3_stop', '3_duration'])) root.time_constrained = False root.remove_child_item(1) assert pulse1.index == 1 assert pulse2.index == 0 assert pulse3.index == 2 assert pulse2.root is None assert (sorted(root.get_accessible_vars()) == sorted(['1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration'])) root.add_child_item(1, pulse2) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse3.index == 3 assert pulse2.root is root assert (sorted(root.get_accessible_vars()) == sorted(['1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration', '3_start', '3_stop', '3_duration']))
def test_sequence_indexing1(): """Test adding, moving, deleting pulse in a sequence. """ root = RootSequence() root.time_constrained = True root.sequence_duration = '1.0' context = TestContext() root.context = context pulse1 = Pulse() pulse2 = Pulse() pulse3 = Pulse() root.add_child_item(0, pulse1) assert pulse1.index == 1 assert pulse1.root is root assert (sorted(root.get_accessible_vars()) == (sorted( ['sequence_end', '1_start', '1_stop', '1_duration']))) root.add_child_item(1, pulse2) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse2.root is root assert (sorted(root.get_accessible_vars()) == sorted([ 'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration' ])) root.move_child_item(0, 1) assert pulse1.index == 2 assert pulse2.index == 1 assert (sorted(root.get_accessible_vars()) == sorted([ 'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration' ])) root.move_child_item(0, 1) root.add_child_item(2, pulse3) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse3.index == 3 assert pulse3.root is root assert (sorted(root.get_accessible_vars()) == sorted([ 'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration', '3_start', '3_stop', '3_duration' ])) root.time_constrained = False root.remove_child_item(1) assert pulse1.index == 1 assert pulse2.index == 0 assert pulse3.index == 2 assert pulse2.root is None assert (sorted(root.get_accessible_vars()) == sorted( ['1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration'])) root.add_child_item(1, pulse2) assert pulse1.index == 1 assert pulse2.index == 2 assert pulse3.index == 3 assert pulse2.root is root assert (sorted(root.get_accessible_vars()) == sorted([ '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration', '3_start', '3_stop', '3_duration' ]))