Пример #1
0
def test_sequence_time_constaints_observation():
    """Test observation of time constraint by the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence = BaseSequence()
    root.add_child_item(0, sequence)

    assert root.global_vars == []

    sequence.time_constrained = True

    assert (sorted(root.global_vars) ==
            sorted(['1_start', '1_stop', '1_duration']))

    sequence.time_constrained = False

    assert root.global_vars == []

    root.time_constrained = True
    assert root.linkable_vars
Пример #2
0
def test_sequence_time_constaints_observation():
    """Test observation of time constraint by the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence = BaseSequence()
    root.add_child_item(0, sequence)

    assert root.global_vars == []

    sequence.time_constrained = True

    assert (sorted(root.global_vars) == sorted(
        ['1_start', '1_stop', '1_duration']))

    sequence.time_constrained = False

    assert root.global_vars == []

    root.time_constrained = True
    assert root.linkable_vars
Пример #3
0
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']))
Пример #4
0
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'
    ]))