Exemplo n.º 1
0
def test_pulse_view(windows, workbench, process_and_sleep):
    """Test the view of the Pulse class.

    """
    from ecpy.testing.util import show_widget
    with enaml.imports():
        from ecpy_pulses.pulses.sequences.views.base_sequences_views\
            import RootSequenceView

    pulse = Pulse(root=RootSequence(context=TestContext()))
    pulse.kind = 'Analogical'
    root = pulse.root
    root.add_child_item(0, pulse)
    core = workbench.get_plugin('enaml.workbench.core')
    root_view = RootSequenceView(item=root, core=core)
    pulse_view = root_view.view_for(pulse)
    show_widget(root_view)
    process_and_sleep()

    # Test selecting a slope shape
    shape_select = pulse_view.widgets()[-1].widgets()[-1]
    shape_select.selected = 'ecpy_pulses.SlopeShape'
    process_and_sleep()

    shape_view = pulse_view.widgets()[-1]
    sv_widgets = shape_view.split_items()[0].split_widget().widgets()

    for mode in ('Start/Stop', 'Start/Slope', 'Slope/Stop'):
        sv_widgets[1].selected = mode
        process_and_sleep()
        assert sv_widgets[2].text == mode.split('/')[0]
        assert sv_widgets[4].text == mode.split('/')[1]
Exemplo n.º 2
0
def test_collect_dependencies(workbench):
    """Test collecting build dependencies.

    """
    from ecpy_pulses.pulses.sequences.base_sequences import RootSequence
    root = RootSequence(context=TestContext())

    pulse1 = Pulse(def_1='1.0', def_2='{7_start} - 1.0')
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='{6_start} + 1.0')
    pulse3 = Pulse(def_1='{3_stop} + 0.5', def_2='10.0')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='{1_stop}', def_2='0.5', def_mode='Start/Duration')
    pulse5.shape = SquareShape(amplitude='0.5')
    pulse5.kind = 'Analogical'

    pulse5.modulation.frequency = '1.0**'
    pulse5.modulation.phase = '1.0'
    pulse5.modulation.activated = True

    sequence2 = BaseSequence()
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    sequence1.add_child_item(0, pulse2)
    sequence1.add_child_item(1, sequence2)
    sequence1.add_child_item(2, pulse4)

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse5)

    core = workbench.get_plugin(u'enaml.workbench.core')
    com = 'ecpy.app.dependencies.analyse'
    dep = core.invoke_command(com, {'obj': root, 'dependencies': 'build'})
    assert not dep.errors

    com = 'ecpy.app.dependencies.collect'
    dep = core.invoke_command(com, {
        'kind': 'build',
        'dependencies': dep.dependencies
    })

    assert not dep.errors
    assert 'ecpy.pulses.item' in dep.dependencies
    assert 'ecpy.pulses.context' in dep.dependencies
    assert 'ecpy.pulses.shape' in dep.dependencies
    assert 'ecpy.pulses.modulation' in dep.dependencies
Exemplo n.º 3
0
def test_collect_dependencies(workbench):
    """Test collecting build dependencies.

    """
    from ecpy_pulses.pulses.sequences.base_sequences import RootSequence
    root = RootSequence(context=TestContext())

    pulse1 = Pulse(def_1='1.0', def_2='{7_start} - 1.0')
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='{6_start} + 1.0')
    pulse3 = Pulse(def_1='{3_stop} + 0.5', def_2='10.0')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='{1_stop}', def_2='0.5',
                   def_mode='Start/Duration')
    pulse5.shape = SquareShape(amplitude='0.5')
    pulse5.kind = 'Analogical'

    pulse5.modulation.frequency = '1.0**'
    pulse5.modulation.phase = '1.0'
    pulse5.modulation.activated = True

    sequence2 = BaseSequence()
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    sequence1.add_child_item(0, pulse2)
    sequence1.add_child_item(1, sequence2)
    sequence1.add_child_item(2, pulse4)

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse5)

    core = workbench.get_plugin(u'enaml.workbench.core')
    com = 'ecpy.app.dependencies.analyse'
    dep = core.invoke_command(com, {'obj': root, 'dependencies': 'build'})
    assert not dep.errors

    com = 'ecpy.app.dependencies.collect'
    dep = core.invoke_command(com, {'kind': 'build',
                                    'dependencies': dep.dependencies})

    assert not dep.errors
    assert 'ecpy.pulses.items' in dep.dependencies
    assert 'ecpy.pulses.contexts' in dep.dependencies
    assert 'ecpy.pulses.shapes' in dep.dependencies
    assert 'ecpy.pulses.modulation' in dep.dependencies