Exemplo n.º 1
0
def test_clear(exopy_qtbot, execution_view, dialog_sleep):
    """Test clearing the enqueued measurements.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    cl_btn = item.dock_widget().widgets()[4]
    assert cl_btn.enabled

    # Check disabled when running
    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    item.workspace.plugin.processor.running_measurement = meas
    item.workspace.plugin.processor.active = True
    assert not cl_btn.enabled

    item.workspace.plugin.processor.active = False
    assert cl_btn.enabled

    measurements = item.workspace.plugin.enqueued_measurements.measurements
    measurements[0].status = 'COMPLETED'
    measurements[1].status = 'FAILED'

    cl_btn.clicked = True

    def assert_enabled():
        assert not item.workspace.plugin.enqueued_measurements.measurements
        assert not cl_btn.enabled

    exopy_qtbot.wait_until(assert_enabled)
Exemplo n.º 2
0
def test_text_monitor_item(exopy_qtbot, text_monitor_workbench, monitor,
                           dialog_sleep):
    """Test that the dock item of the text monitor does display the right
    entries.

    """
    # Check only displayed entries are indeed shown.
    monitor.handle_database_entries_change(('added', 'root/test', 0))
    monitor.handle_database_entries_change(('added', 'root/simp/test', 0))
    monitor.handle_database_entries_change(('added', 'root/comp/index', 0))
    monitor.move_entries('displayed', 'undisplayed',
                         [monitor.displayed_entries[0]])
    w = DockItemTestingWindow(widget=TextMonitorItem(monitor=monitor,
                                                     name='test'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    f = w.widget.dock_widget()
    assert (sorted([l.text for l in f.widgets()[::2]]) ==
            sorted([e.name for e in monitor.displayed_entries]))
    exopy_qtbot.wait(dialog_sleep)

    e = sorted(monitor.displayed_entries, key=attrgetter('path'))[0]
    e.name = 'new'
    e.value = '1'

    def assert_text():
        assert f.widgets()[0].text == 'new'
        assert f.widgets()[1].text == '1'
    exopy_qtbot.wait_until(assert_text)
Exemplo n.º 3
0
def test_selecting_profile_from_scratch(prof_plugin, exopy_qtbot,
                                        dialog_sleep):
    """Test selecting a profile.

    """
    d = ProfileSelectionDialog(plugin=prof_plugin)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    d.profile = 'fp2'
    assert not d.connection
    assert not d.settings
    exopy_qtbot.wait(10 + dialog_sleep)

    d.connection = 'false_connection1'
    d.settings = 'false_settings1'
    d.driver = 'instruments.test.FalseDriver%s' % ('' if d.driver.endswith('2')
                                                   else 2)
    assert not d.connection
    assert not d.settings
    exopy_qtbot.wait(10 + dialog_sleep)

    d.connection = 'false_connection'
    d.settings = 'false_settings'
    exopy_qtbot.wait(10 + dialog_sleep)

    d.central_widget().widgets()[-1].clicked = True

    def assert_result():
        assert d.result
    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 4
0
def test_copy_paste_action(measurement, workspace, exopy_qtbot,
                           dialog_sleep, edition_view):
    """Test that copy-and-pasting a task does work.

    """
    edition_view.show()
    edition_view.maximize()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    tree = ed.widgets()[5]

    task = measurement.root_task.children[0]

    action = TaskCopyAction(workspace=workspace,
                            action_context=dict(copyable=True,
                                                data=(None, None, task, None)))
    action.triggered = True

    action = TaskPasteAction(action_context=dict(pasteable=True,
                                                 data=(tree,
                                                       tree.nodes[0],
                                                       measurement.root_task,
                                                       None)))
    action.triggered = True
    assert "(copy)Test" in measurement.root_task.get_used_names()
Exemplo n.º 5
0
def test_copy_paste_action(measurement, workspace, exopy_qtbot,
                           dialog_sleep, edition_view):
    """Test that copy-and-pasting a task does work.

    """
    edition_view.show()
    edition_view.maximize()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    tree = ed.widgets()[5]

    task = measurement.root_task.children[0]

    action = TaskCopyAction(workspace=workspace,
                            action_context=dict(copyable=True,
                                                data=(None, None, task, None)))
    action.triggered = True

    action = TaskPasteAction(action_context=dict(pasteable=True,
                                                 data=(tree,
                                                       tree.nodes[0],
                                                       measurement.root_task,
                                                       None)))
    action.triggered = True
    assert "(copy)Test" in measurement.root_task.get_used_names()
Exemplo n.º 6
0
def test_model_selection_widget(exopy_qtbot, instr_workbench, dialog_sleep):
    """Test the capabilities of the model selection widget.

    """
    instr_workbench.register(InstrContributor1())
    p = instr_workbench.get_plugin('exopy.instruments')

    h = p._manufacturers

    d = ModelSelectionDialog(plugin=p)
    sel = d.central_widget().widgets()[0]
    tr = sel.widgets()[-1]
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    tr.auto_expand = True
    sel.kind = 'Lock-in'

    def assert_manufacturers():
        assert len(h.manufacturers) == 1

    exopy_qtbot.wait_until(assert_manufacturers)
    exopy_qtbot.wait(dialog_sleep)

    sel.kind = 'All'
    tr.selected_item = h._manufacturers['Dummy']

    def assert_manufacturers():
        assert len(h._manufacturers['Dummy'].instruments) == 2

    exopy_qtbot.wait_until(assert_manufacturers)
    exopy_qtbot.wait(dialog_sleep)

    sel.use_series = False

    def assert_use_series():
        assert h.use_series == sel.use_series

    exopy_qtbot.wait_until(assert_use_series)
    exopy_qtbot.wait(dialog_sleep)
    assert len(h._manufacturers['Dummy'].instruments) == 3

    sel.use_series = True

    tr.selected_item = h._manufacturers['Dummy']._series['dumb']
    exopy_qtbot.wait(100)
    exopy_qtbot.wait(dialog_sleep)

    tr.selected_item = h._manufacturers['Dummy']._models['001']
    exopy_qtbot.wait(100)
    exopy_qtbot.wait(dialog_sleep)

    d.central_widget().widgets()[-1].clicked = True

    def assert_model():
        assert d.instr_model

    exopy_qtbot.wait_until(assert_model)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 7
0
def test_show_monitors(exopy_qtbot, execution_view, dialog_sleep):
    """Test restoring the monitor window.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    mon_btn = item.dock_widget().widgets()[5]
    assert not mon_btn.enabled

    with enaml.imports():
        from exopy.measurement.workspace.monitors_window import MonitorsWindow

    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    mon_win = MonitorsWindow(item, measurement=meas)
    item.workspace.plugin.processor.monitors_window = mon_win

    assert not mon_win.visible

    mon_btn.clicked = True

    def assert_visible():
        assert mon_win.visible

    exopy_qtbot.wait_until(assert_visible)
Exemplo n.º 8
0
def test_selecting_profile_from_scratch(prof_plugin, exopy_qtbot,
                                        dialog_sleep):
    """Test selecting a profile.

    """
    d = ProfileSelectionDialog(plugin=prof_plugin)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    d.profile = 'fp2'
    assert not d.connection
    assert not d.settings
    exopy_qtbot.wait(10 + dialog_sleep)

    d.connection = 'false_connection1'
    d.settings = 'false_settings1'
    d.driver = 'instruments.test.FalseDriver%s' % ('' if d.driver.endswith('2')
                                                   else 2)
    assert not d.connection
    assert not d.settings
    exopy_qtbot.wait(10 + dialog_sleep)

    d.connection = 'false_connection'
    d.settings = 'false_settings'
    exopy_qtbot.wait(10 + dialog_sleep)

    d.central_widget().widgets()[-1].clicked = True

    def assert_result():
        assert d.result

    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 9
0
def test_text_monitor_item(exopy_qtbot, text_monitor_workbench, monitor,
                           dialog_sleep):
    """Test that the dock item of the text monitor does display the right
    entries.

    """
    # Check only displayed entries are indeed shown.
    monitor.handle_database_entries_change(('added', 'root/test', 0))
    monitor.handle_database_entries_change(('added', 'root/simp/test', 0))
    monitor.handle_database_entries_change(('added', 'root/comp/index', 0))
    monitor.move_entries('displayed', 'undisplayed',
                         [monitor.displayed_entries[0]])
    w = DockItemTestingWindow(widget=TextMonitorItem(monitor=monitor,
                                                     name='test'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    f = w.widget.dock_widget()
    assert (sorted([l.text for l in f.widgets()[::2]]) ==
            sorted([e.name for e in monitor.displayed_entries]))
    exopy_qtbot.wait(dialog_sleep)

    e = sorted(monitor.displayed_entries, key=attrgetter('path'))[0]
    e.name = 'new'
    e.value = '1'

    def assert_text():
        assert f.widgets()[0].text == 'new'
        assert f.widgets()[1].text == '1'
    exopy_qtbot.wait_until(assert_text)
Exemplo n.º 10
0
def test_clear(exopy_qtbot, execution_view, dialog_sleep):
    """Test clearing the enqueued measurements.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    cl_btn = item.dock_widget().widgets()[4]
    assert cl_btn.enabled

    # Check disabled when running
    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    item.workspace.plugin.processor.running_measurement = meas
    item.workspace.plugin.processor.active = True
    assert not cl_btn.enabled

    item.workspace.plugin.processor.active = False
    assert cl_btn.enabled

    measurements = item.workspace.plugin.enqueued_measurements.measurements
    measurements[0].status = 'COMPLETED'
    measurements[1].status = 'FAILED'

    cl_btn.clicked = True

    def assert_enabled():
        assert not item.workspace.plugin.enqueued_measurements.measurements
        assert not cl_btn.enabled

    exopy_qtbot.wait_until(assert_enabled)
Exemplo n.º 11
0
def test_measurement_manipulations(exopy_qtbot, execution_view, dialog_sleep):
    """Test moving/removing measurement using editor

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    ed = item.dock_widget().widgets()[0]
    meas = item.workspace.plugin.enqueued_measurements.measurements
    ed.operations['move'](0, 1)

    def assert_meas_name():
        assert meas[0].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)

    ed.operations['move'](0, 1)

    def assert_meas_name():
        assert meas[1].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)

    ed.operations['remove'](0)

    def assert_meas_name():
        assert meas[0].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)
    assert len(meas) == 1
Exemplo n.º 12
0
def test_browing_dialog_profiles_delete(exopy_qtbot, prof_plugin,
                                        dialog_sleep):
    """Test the browsing dialog page dedicated to explore the profiles.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    nb.selected_tab = 'profiles'
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    c = nb.pages()[0].page_widget()
    btn = c.widgets()[-1]
    c.p_id = 'fp1'
    print(prof_plugin._profiles)

    with handle_dialog(exopy_qtbot, 'reject', cls=MessageBox):
        btn.clicked = True

    assert 'fp1' in prof_plugin._profiles

    def handle(bot, dial):
        dial.buttons[0].was_clicked = True

    with handle_dialog(exopy_qtbot, 'accept', handle, cls=MessageBox):
        btn.clicked = True

    exopy_qtbot.wait(1000)

    def assert_profiles():
        assert 'fp1' not in prof_plugin._profiles

    exopy_qtbot.wait_until(assert_profiles)
Exemplo n.º 13
0
def test_browsing_dialog_profiles_use(prof_plugin, exopy_qtbot, dialog_sleep):
    """Test the browsing dialog page dedicated to follow the use of profiles.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    nb.selected_tab = 'profile_use'
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    f = nb.pages()[1].page_widget().widgets()[0].scroll_widget()
    assert len(f.widgets()) == 2
    p, m = prof_plugin.get_profiles('tests2', ['fp1', 'fp2'])
    assert len(p) == 2

    # Debug print
    print(f.children[-1].iterable)

    def assert_children():
        assert len(f.widgets()) == 6

    exopy_qtbot.wait_until(assert_children)
    exopy_qtbot.wait(dialog_sleep)

    prof_plugin.release_profiles('tests2', ['fp2'])

    def assert_children():
        assert len(f.widgets()) == 4

    exopy_qtbot.wait_until(assert_children)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 14
0
def test_connection_validation_window(prof_plugin, exopy_qtbot, dialog_sleep,
                                      profile_infos):
    """Test the window used to check that connection infos allows to open a
    connection.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    wait_for_window_displayed(exopy_qtbot, ed)
    exopy_qtbot.wait(dialog_sleep)

    w = ConnectionValidationWindow(editor=ed.central_widget().widgets()[0])
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    exopy_qtbot.wait(dialog_sleep)

    # XXX need to select a driver

    widgets = w.central_widget().widgets()
    p = widgets[-3]
    p.clicked = True
    assert 'The connection was successfully established' in widgets[-2].text

    # XXX add a test for failed connection test

    widgets[-1].clicked = True
    exopy_qtbot.wait(10)
Exemplo n.º 15
0
def test_engine_status(exopy_qtbot, execution_view, dialog_sleep):
    """Test the display of the engine status.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget
    del item.workspace.plugin.processor.engine

    en_stat = item.dock_widget().widgets()[-1]
    assert not en_stat.visible

    pl = item.workspace.plugin
    pl.processor.engine = pl.create('engine', 'dummy')
    pl.processor.engine.status = 'Stopped'

    def assert_visible():
        assert en_stat.visible
    exopy_qtbot.wait_until(assert_visible)

    def assert_status():
        assert en_stat.widgets()[1].text == 'Stopped'
    exopy_qtbot.wait_until(assert_status)

    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    item.workspace.plugin.processor.running_measurement = meas
    item.workspace.plugin.processor.active = True

    assert not en_stat.widgets()[2].enabled
    assert en_stat.widgets()[2].text == 'Shut down'
Exemplo n.º 16
0
def test_browsing_dialog_profiles_use(prof_plugin, exopy_qtbot, dialog_sleep):
    """Test the browsing dialog page dedicated to follow the use of profiles.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    nb.selected_tab = 'profile_use'
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    f = nb.pages()[1].page_widget().widgets()[0].scroll_widget()
    assert len(f.widgets()) == 2
    p, m = prof_plugin.get_profiles('tests2', ['fp1', 'fp2'])
    assert len(p) == 2

    # Debug print
    print(f.children[-1].iterable)

    def assert_children():
        assert len(f.widgets()) == 6
    exopy_qtbot.wait_until(assert_children)
    exopy_qtbot.wait(dialog_sleep)

    prof_plugin.release_profiles('tests2', ['fp2'])

    def assert_children():
        assert len(f.widgets()) == 4
    exopy_qtbot.wait_until(assert_children)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 17
0
def test_engine_status(exopy_qtbot, execution_view, dialog_sleep):
    """Test the display of the engine status.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget
    del item.workspace.plugin.processor.engine

    en_stat = item.dock_widget().widgets()[-1]
    assert not en_stat.visible

    pl = item.workspace.plugin
    pl.processor.engine = pl.create('engine', 'dummy')
    pl.processor.engine.status = 'Stopped'

    def assert_visible():
        assert en_stat.visible
    exopy_qtbot.wait_until(assert_visible)

    assert en_stat.widgets()[1].text == 'Stopped'

    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    item.workspace.plugin.processor.running_measurement = meas
    item.workspace.plugin.processor.active = True

    assert not en_stat.widgets()[2].enabled
    assert en_stat.widgets()[2].text == 'Shut down'
Exemplo n.º 18
0
def test_browing_dialog_profiles_delete(exopy_qtbot, prof_plugin,
                                        dialog_sleep):
    """Test the browsing dialog page dedicated to explore the profiles.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    nb.selected_tab = 'profiles'
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    c = nb.pages()[0].page_widget()
    btn = c.widgets()[-1]
    c.p_id = 'fp1'
    print(prof_plugin._profiles)

    with handle_dialog(exopy_qtbot, 'reject', cls=MessageBox):
        btn.clicked = True

    assert 'fp1' in prof_plugin._profiles

    def handle(bot, dial):
        dial.buttons[0].was_clicked = True

    with handle_dialog(exopy_qtbot, 'accept', handle, cls=MessageBox):
        btn.clicked = True

    exopy_qtbot.wait(1000)

    def assert_profiles():
        assert 'fp1' not in prof_plugin._profiles
    exopy_qtbot.wait_until(assert_profiles)
Exemplo n.º 19
0
def test_measurement_manipulations(exopy_qtbot, execution_view, dialog_sleep):
    """Test moving/removing measurement using editor

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    ed = item.dock_widget().widgets()[0]
    meas = item.workspace.plugin.enqueued_measurements.measurements
    ed.operations['move'](0, 1)

    def assert_meas_name():
        assert meas[0].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)

    ed.operations['move'](0, 1)

    def assert_meas_name():
        assert meas[1].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)

    ed.operations['remove'](0)

    def assert_meas_name():
        assert meas[0].name == 'dummy_test'
    exopy_qtbot.wait_until(assert_meas_name)
    assert len(meas) == 1
Exemplo n.º 20
0
def test_measurement_edition_dialog(exopy_qtbot, workspace, measurement,
                                    monkeypatch, dialog_sleep):
    """Test creating a measurement edition dialog.

    """
    dialog = MeasureEditorDialog(workspace=workspace, measurement=measurement)
    dialog.show()
    wait_for_window_displayed(exopy_qtbot, dialog)
    exopy_qtbot.wait(dialog_sleep)

    from exopy.measurement.workspace.workspace import MeasurementSpace

    def false_save(self, meas, *args, **kwargs):
        false_save.called = 1

    monkeypatch.setattr(MeasurementSpace, 'save_measurement', false_save)

    btn = dialog.central_widget().widgets()[-1]
    btn.clicked = True

    def assert_called():
        assert false_save.called
    exopy_qtbot.wait_until(assert_called)

    dialog.close()
    wait_for_destruction(exopy_qtbot, dialog)
Exemplo n.º 21
0
def test_connection_validation_window(prof_plugin, exopy_qtbot, dialog_sleep,
                                      profile_infos):
    """Test the window used to check that connection infos allows to open a
    connection.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    wait_for_window_displayed(exopy_qtbot, ed)
    exopy_qtbot.wait(dialog_sleep)

    w = ConnectionValidationWindow(editor=ed.central_widget().widgets()[0])
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    exopy_qtbot.wait(dialog_sleep)

    widgets = w.central_widget().widgets()
    form_widgets = widgets[0].widgets()
    combo_driver = form_widgets[1]
    combo_connection = form_widgets[3]
    combo_settings = form_widgets[5]

    combo_driver.selected = 'test <instruments.test.FalseDriver2>'
    combo_connection.selected = 'false_connection2'
    combo_settings.selected = 'false_settings2'

    p = widgets[-3]
    p.clicked = True
    assert 'The connection was successfully established' in widgets[-2].text

    # XXX add a test for failed connection test

    widgets[-1].clicked = True
    exopy_qtbot.wait(10)
Exemplo n.º 22
0
def test_connection_validation_window(prof_plugin, exopy_qtbot, dialog_sleep,
                                      profile_infos):
    """Test the window used to check that connection infos allows to open a
    connection.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    wait_for_window_displayed(exopy_qtbot, ed)
    exopy_qtbot.wait(dialog_sleep)

    w = ConnectionValidationWindow(editor=ed.central_widget().widgets()[0])
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    exopy_qtbot.wait(dialog_sleep)

    widgets = w.central_widget().widgets()
    form_widgets = widgets[0].widgets()
    combo_driver = form_widgets[1]
    combo_connection = form_widgets[3]
    combo_settings = form_widgets[5]

    combo_driver.selected = 'test <instruments.test.FalseDriver2>'
    combo_connection.selected = 'false_connection2'
    combo_settings.selected = 'false_settings2'

    p = widgets[-3]
    p.clicked = True
    assert 'The connection was successfully established' in widgets[-2].text

    # XXX add a test for failed connection test

    widgets[-1].clicked = True
    exopy_qtbot.wait(10)
Exemplo n.º 23
0
def test_show_monitors(exopy_qtbot, execution_view, dialog_sleep):
    """Test restoring the monitor window.

    """
    execution_view.show()
    wait_for_window_displayed(exopy_qtbot, execution_view)
    exopy_qtbot.wait(dialog_sleep)

    item = execution_view.widget

    mon_btn = item.dock_widget().widgets()[5]
    assert not mon_btn.enabled

    with enaml.imports():
        from exopy.measurement.workspace.monitors_window import MonitorsWindow

    meas = item.workspace.plugin.enqueued_measurements.measurements[0]
    mon_win = MonitorsWindow(item, measurement=meas)
    item.workspace.plugin.processor.monitors_window = mon_win

    assert not mon_win.visible

    mon_btn.clicked = True

    def assert_visible():
        assert mon_win.visible

    exopy_qtbot.wait_until(assert_visible)
Exemplo n.º 24
0
def test_measurement_edition_dialog(exopy_qtbot, workspace, measurement,
                                    monkeypatch, dialog_sleep):
    """Test creating a measurement edition dialog.

    """
    dialog = MeasureEditorDialog(workspace=workspace, measurement=measurement)
    dialog.show()
    wait_for_window_displayed(exopy_qtbot, dialog)
    exopy_qtbot.wait(dialog_sleep)

    from exopy.measurement.workspace.workspace import MeasurementSpace

    def false_save(self, meas, *args, **kwargs):
        false_save.called = 1

    monkeypatch.setattr(MeasurementSpace, 'save_measurement', false_save)

    btn = dialog.central_widget().widgets()[-1]
    btn.clicked = True

    def assert_called():
        assert false_save.called

    exopy_qtbot.wait_until(assert_called)

    dialog.close()
    wait_for_destruction(exopy_qtbot, dialog)
Exemplo n.º 25
0
def test_switching_between_tasks(exopy_qtbot, edition_view, dialog_sleep):
    """Test switching between tasks which lead to different selected editors.

    """
    edition_view.show()
    edition_view.maximize()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]

    nb = ed.widgets()[-1]
    nb.selected_tab = 'exopy.database_access'
    exopy_qtbot.wait(10 + dialog_sleep)

    tree = ed.widgets()[5]
    tree.selected_item = ed.measurement.root_task.children[0]

    def assert_tab():
        assert nb.selected_tab == 'exopy.standard'

    exopy_qtbot.wait_until(assert_tab)

    tree.selected_item = ed.measurement.root_task
    exopy_qtbot.wait(10 + dialog_sleep)
Exemplo n.º 26
0
def test_model_selection_widget(exopy_qtbot, instr_workbench, dialog_sleep):
    """Test the capabilities of the model selection widget.

    """
    instr_workbench.register(InstrContributor1())
    p = instr_workbench.get_plugin('exopy.instruments')

    h = p._manufacturers

    d = ModelSelectionDialog(plugin=p)
    sel = d.central_widget().widgets()[0]
    tr = sel.widgets()[-1]
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    tr.auto_expand = True
    sel.kind = 'Lock-in'

    def assert_manufacturers():
        assert len(h.manufacturers) == 1
    exopy_qtbot.wait_until(assert_manufacturers)
    exopy_qtbot.wait(dialog_sleep)

    sel.kind = 'All'
    tr.selected_item = h._manufacturers['Dummy']

    def assert_manufacturers():
        assert len(h._manufacturers['Dummy'].instruments) == 2
    exopy_qtbot.wait_until(assert_manufacturers)
    exopy_qtbot.wait(dialog_sleep)

    sel.use_series = False

    def assert_use_series():
        assert h.use_series == sel.use_series
    exopy_qtbot.wait_until(assert_use_series)
    exopy_qtbot.wait(dialog_sleep)
    assert len(h._manufacturers['Dummy'].instruments) == 3

    sel.use_series = True

    tr.selected_item = h._manufacturers['Dummy']._series['dumb']
    exopy_qtbot.wait(100)
    exopy_qtbot.wait(dialog_sleep)

    tr.selected_item = h._manufacturers['Dummy']._models['001']
    exopy_qtbot.wait(100)
    exopy_qtbot.wait(dialog_sleep)

    d.central_widget().widgets()[-1].clicked = True

    def assert_model():
        assert d.instr_model
    exopy_qtbot.wait_until(assert_model)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 27
0
def test_elusiveicon(icon_workbench, exopy_qtbot):
    """Test getting and using an ElusiveIcon icon.

    """
    pl = icon_workbench.get_plugin('exopy.app.icons')
    pl.current_theme = 'exopy.ElusiveIcon'
    assert pl.get_icon('folder-open')
    w = IconWindowTest(btn_icon=pl.get_icon('folder-open'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
Exemplo n.º 28
0
def test_elusiveicon(icon_workbench, exopy_qtbot):
    """Test getting and using an ElusiveIcon icon.

    """
    pl = icon_workbench.get_plugin('exopy.app.icons')
    pl.current_theme = 'exopy.ElusiveIcon'
    assert pl.get_icon('folder-open')
    w = IconWindowTest(btn_icon=pl.get_icon('folder-open'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
Exemplo n.º 29
0
def test_fontawesome(icon_workbench, exopy_qtbot, dialog_sleep):
    """Test getting and using a FontAwesome icon.

    """
    pl = icon_workbench.get_plugin('exopy.app.icons')
    pl.current_theme = 'exopy.FontAwesome'
    assert pl.get_icon('folder-open')
    w = IconWindowTest(btn_icon=pl.get_icon('folder-open'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
Exemplo n.º 30
0
def test_fontawesome(icon_workbench, exopy_qtbot, dialog_sleep):
    """Test getting and using a FontAwesome icon.

    """
    pl = icon_workbench.get_plugin('exopy.app.icons')
    pl.current_theme = 'exopy.FontAwesome'
    assert pl.get_icon('folder-open')
    w = IconWindowTest(btn_icon=pl.get_icon('folder-open'))
    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
Exemplo n.º 31
0
def test_editing_cusom_entry(monitor, exopy_qtbot, dialog_sleep):
    """Test that we can edit an existing monitored entry.

    """
    e = MonitoredEntry(
        name='test',
        path='test',
        depend_on=['root/test', 'root/simp/test', 'root/comp/test'],
        formatting=('{root/test}, {root/simp/test}, '
                    '{root/comp/test}'))

    # Test cancelling after editon.
    d = EntryDialog(monitor=monitor, entry=e)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()
    assert w[1].text == 'test'
    w[1].text = 'dummy'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-1].clicked = True

    def assert_name():
        assert d.entry.name == 'test'

    exopy_qtbot.wait_until(assert_name)

    # Test doing some actuel editions
    d = EntryDialog(monitor=monitor, entry=e)
    d.show()
    exopy_qtbot.wait(10 + dialog_sleep)

    w = d.central_widget().widgets()
    w[1].text = 'test2'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[5].text = '{simp/test}, {comp/test}'
    exopy_qtbot.wait(10 + dialog_sleep)

    b = d.builder
    assert b.used_entries[0].entry == 'root/test'
    b.remove_entry(0)
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-2].clicked = True

    def assert_name():
        e = d.entry
        assert e.name == 'test2'
        assert (sorted(e.depend_on) == sorted(
            ('root/simp/test', 'root/comp/test')))

    exopy_qtbot.wait_until(assert_name)
Exemplo n.º 32
0
def test_creating_new_custom_entry(monitor, exopy_qtbot, dialog_sleep):
    """Test creating an  entry using the dialog.

    """
    d = EntryDialog(monitor=monitor)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()
    w[1].text = 'test'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[5].text = '{root/test}, {simp/test}, {comp/test}'
    exopy_qtbot.wait(10 + dialog_sleep)

    b = d.builder
    for e in ('root/test', 'simp/test', 'comp/test'):
        assert e in b.map_entries
    b.add_entry(0, 'after')
    assert b.used_entries
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[0].entry = 'root/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    b.add_entry(0, 'after')
    assert not b.used_entries[-1].entry
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[-1].entry = 'simp/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    b.add_entry(0, 'before')
    assert not b.used_entries[0].entry
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[0].entry = 'comp/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-2].clicked = True

    def assert_entry():
        assert d.entry

    exopy_qtbot.wait_until(assert_entry)

    e = d.entry
    assert e.name == 'test'
    assert (sorted(e.depend_on) == sorted(
        ('root/test', 'root/simp/test', 'root/comp/test')))

    d.close()
    wait_for_destruction(exopy_qtbot, d)
Exemplo n.º 33
0
def test_measurement_view(measurement, exopy_qtbot, dialog_sleep, monkeypatch,
                          workspace):
    """Test that the displayed buttons do reflect the state of the measurement.

    """
    measurement.status = 'READY'
    view = MeasView(model=measurement)
    w = ContainerTestingWindow(widget=view)

    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    exopy_qtbot.wait(dialog_sleep)

    assert view.widgets()[2].enabled  # cd1 inserted its children before itself

    def test_state(bot, dial):
        assert dial.measurement.status == 'EDITING'

    with handle_dialog(exopy_qtbot, 'reject', handler=test_state):
        view.widgets()[2].clicked = True

    assert view.widgets()[-1].enabled
    measurement.plugin.processor.active = True

    def assert_enabled():
        assert not view.widgets()[-1].enabled

    exopy_qtbot.wait_until(assert_enabled)
    measurement.plugin.processor.active = False

    from exopy.measurement.workspace.workspace import MeasurementSpace
    spy = CallSpy()
    monkeypatch.setattr(MeasurementSpace, 'process_single_measurement', spy)
    view.widgets()[-1].clicked = True
    assert spy.called

    measurement.status = 'RUNNING'

    def assert_widgets():
        assert len(view.widgets()) == 2

    exopy_qtbot.wait_until(assert_widgets)

    measurement.status = 'COMPLETED'

    def assert_widgets():
        assert len(view.widgets()) == 3

    exopy_qtbot.wait_until(assert_widgets)
    spy = CallSpy()
    monkeypatch.setattr(MeasurementSpace, 'reenqueue_measurement', spy)
    view.widgets()[-1].clicked = True

    assert view.widgets()[1].text == 'COMPLETED'
Exemplo n.º 34
0
def test_editing_cusom_entry(monitor, exopy_qtbot, dialog_sleep):
    """Test that we can edit an existing monitored entry.

    """
    e = MonitoredEntry(name='test', path='test',
                       depend_on=['root/test', 'root/simp/test',
                                  'root/comp/test'],
                       formatting=('{root/test}, {root/simp/test}, '
                                   '{root/comp/test}')
                       )

    # Test cancelling after editon.
    d = EntryDialog(monitor=monitor, entry=e)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()
    assert w[1].text == 'test'
    w[1].text = 'dummy'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-1].clicked = True

    def assert_name():
        assert d.entry.name == 'test'
    exopy_qtbot.wait_until(assert_name)

    # Test doing some actuel editions
    d = EntryDialog(monitor=monitor, entry=e)
    d.show()
    exopy_qtbot.wait(10 + dialog_sleep)

    w = d.central_widget().widgets()
    w[1].text = 'test2'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[5].text = '{simp/test}, {comp/test}'
    exopy_qtbot.wait(10 + dialog_sleep)

    b = d.builder
    assert b.used_entries[0].entry == 'root/test'
    b.remove_entry(0)
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-2].clicked = True

    def assert_name():
        e = d.entry
        assert e.name == 'test2'
        assert (sorted(e.depend_on) ==
                sorted(('root/simp/test', 'root/comp/test')))
    exopy_qtbot.wait_until(assert_name)
Exemplo n.º 35
0
def test_creating_new_custom_entry(monitor, exopy_qtbot, dialog_sleep):
    """Test creating an  entry using the dialog.

    """
    d = EntryDialog(monitor=monitor)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()
    w[1].text = 'test'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[5].text = '{root/test}, {simp/test}, {comp/test}'
    exopy_qtbot.wait(10 + dialog_sleep)

    b = d.builder
    for e in ('root/test', 'simp/test', 'comp/test'):
        assert e in b.map_entries
    b.add_entry(0, 'after')
    assert b.used_entries
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[0].entry = 'root/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    b.add_entry(0, 'after')
    assert not b.used_entries[-1].entry
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[-1].entry = 'simp/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    b.add_entry(0, 'before')
    assert not b.used_entries[0].entry
    exopy_qtbot.wait(10 + dialog_sleep)

    b.used_entries[0].entry = 'comp/test'
    exopy_qtbot.wait(10 + dialog_sleep)

    w[-2].clicked = True

    def assert_entry():
        assert d.entry
    exopy_qtbot.wait_until(assert_entry)

    e = d.entry
    assert e.name == 'test'
    assert (sorted(e.depend_on) ==
            sorted(('root/test', 'root/simp/test', 'root/comp/test')))

    d.close()
    wait_for_destruction(exopy_qtbot, d)
Exemplo n.º 36
0
def test_measurement_view(measurement, exopy_qtbot, dialog_sleep, monkeypatch,
                          workspace):
    """Test that the displayed buttons do reflect the state of the measurement.

    """
    measurement.status = 'READY'
    view = MeasView(model=measurement)
    w = ContainerTestingWindow(widget=view)

    w.show()
    wait_for_window_displayed(exopy_qtbot, w)
    exopy_qtbot.wait(dialog_sleep)

    assert view.widgets()[2].enabled  # cd1 inserted its children before itself

    def test_state(bot, dial):
        assert dial.measurement.status == 'EDITING'

    with handle_dialog(exopy_qtbot, 'reject', handler=test_state):
        view.widgets()[2].clicked = True

    assert view.widgets()[-1].enabled
    measurement.plugin.processor.active = True

    def assert_enabled():
        assert not view.widgets()[-1].enabled
    exopy_qtbot.wait_until(assert_enabled)
    measurement.plugin.processor.active = False

    from exopy.measurement.workspace.workspace import MeasurementSpace
    spy = CallSpy()
    monkeypatch.setattr(MeasurementSpace, 'process_single_measurement', spy)
    view.widgets()[-1].clicked = True
    assert spy.called

    measurement.status = 'RUNNING'

    def assert_widgets():
        assert len(view.widgets()) == 2
    exopy_qtbot.wait_until(assert_widgets)

    measurement.status = 'COMPLETED'

    def assert_widgets():
        assert len(view.widgets()) == 3
    exopy_qtbot.wait_until(assert_widgets)
    spy = CallSpy()
    monkeypatch.setattr(MeasurementSpace, 'reenqueue_measurement', spy)
    view.widgets()[-1].clicked = True

    assert view.widgets()[1].text == 'COMPLETED'
Exemplo n.º 37
0
def test_using_custom_filtering(prof_plugin, exopy_qtbot, dialog_sleep):
    """Test using a custom filtering function to reduce the available profiles
    and drivers.

    """
    d = ProfileSelectionDialog(plugin=prof_plugin, profile='fp1',
                               filter_profiles=lambda p: ['fp1'],
                               filter_drivers=lambda d: [d[0]])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()[0]
    assert len(w._drivers) == 1
Exemplo n.º 38
0
def test_settings_creation_dialog(prof_plugin, model_infos, exopy_qtbot,
                                  dialog_sleep):
    """Test the dialog dedicated to create new settings.

    """
    d = SettingsCreationDialog(plugin=prof_plugin,
                               model_infos=model_infos,
                               existing=['false_settings2'])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    assert d.settings
    assert len(d._settings) == 3

    ws = d.central_widget().widgets()
    ws[0].selected_item = ws[0].items[1]
    ok = ws[-1]

    def assert_enabled():
        assert not ok.enabled

    exopy_qtbot.wait_until(assert_enabled)
    exopy_qtbot.wait(dialog_sleep)

    n = ws[-3]
    n.text = 'dummy'
    assert ok.enabled

    n.validator.validate('false_settings2')
    assert not ok.enabled

    n = ws[-3]
    n.text = 'dummy'
    ok.clicked = True
    assert d.settings.user_id == n.text
    assert d.result

    d2 = SettingsCreationDialog(plugin=prof_plugin,
                                model_infos=model_infos,
                                existing=['false_settings2'])
    d2.show()
    wait_for_window_displayed(exopy_qtbot, d2)
    d2.central_widget().widgets()[-2].clicked = False  # Cancel button

    def assert_result():
        assert not d2.result

    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 39
0
def test_using_custom_filtering(prof_plugin, exopy_qtbot, dialog_sleep):
    """Test using a custom filtering function to reduce the available profiles
    and drivers.

    """
    d = ProfileSelectionDialog(plugin=prof_plugin,
                               profile='fp1',
                               filter_profiles=lambda p: ['fp1'],
                               filter_drivers=lambda d: [d[0]])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    w = d.central_widget().widgets()[0]
    assert len(w._drivers) == 1
Exemplo n.º 40
0
def test_creating_tools_edition_panel(exopy_qtbot, edition_view, dialog_sleep):
    """Test creating the tool edition panel using the button.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    btn = ed.widgets()[4]

    btn.clicked = True

    def assert_created():
        assert len(edition_view.area.dock_items()) == 2
    exopy_qtbot.wait_until(assert_created)
Exemplo n.º 41
0
def test_switching_the_linked_measurement(exopy_qtbot, edition_view, dialog_sleep):
    """Test changing the measurement edited by the editor.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]

    ed.measurement = m_build(ed.workspace.workbench)

    def assert_selected():
        tree = ed.widgets()[5]
        assert tree.selected_item == ed.measurement.root_task
    exopy_qtbot.wait_until(assert_selected)
Exemplo n.º 42
0
def test_creating_tools_edition_panel(exopy_qtbot, edition_view, dialog_sleep):
    """Test creating the tool edition panel using the button.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    btn = ed.widgets()[4]

    btn.clicked = True

    def assert_created():
        assert len(edition_view.area.dock_items()) == 2
    exopy_qtbot.wait_until(assert_created)
Exemplo n.º 43
0
def test_compiling_a_sequence_not_compiling2(workspace, root, monkeypatch,
                                             exopy_qtbot, dialog_sleep):
    """Test compiling a sequence that can be evaluated but not compiled.

    """
    def __raise(*args, **kwargs):
        return False, {}, {'test': False}
    from exopy_pulses.testing.context import TestContext
    monkeypatch.setattr(TestContext, 'compile_and_transfer_sequence',
                        __raise)
    workbench = workspace.workbench
    ui = workbench.get_plugin('enaml.workbench.ui')
    ui.show_window()
    exopy_qtbot.wait(10 + dialog_sleep)

    root.external_vars = OrderedDict({'a': 1.5})

    pulse1 = Pulse(def_1='1.0', def_2='{a}')
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='3.0')
    pulse3 = Pulse(def_1='{4_start} + 0.5',
                   def_2='{4_start}+{4_duration}-0.5')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='3.0', def_2='0.5', def_mode='Start/Duration')

    sequence2 = BaseSequence(time_constrained=True,
                             def_1='{3_stop} + 0.5', def_2='6')
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    add_children(sequence1, (pulse2, sequence2, pulse4))

    add_children(root, (pulse1, sequence1, pulse5))

    workspace.state.sequence = root

    dial = CompileDialog(workspace=workspace)
    dial.show()
    wait_for_window_displayed(exopy_qtbot, dial)

    comp_widget = dial.central_widget().widgets()[0]

    comp_widget.widgets()[-1].clicked = True

    def assert_exec():
        assert comp_widget.elapsed_time
        assert comp_widget.errors
        assert comp_widget.widgets()[-2].background == parse_color('red')
    exopy_qtbot.wait_until(assert_exec)
Exemplo n.º 44
0
def test_switching_the_linked_measurement(exopy_qtbot, measurement,
                                          edition_view, dialog_sleep):
    """Test changing the measurement edited by the editor.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]

    ed.measurement = measurement

    def assert_selected():
        tree = ed.widgets()[5]
        assert tree.selected_item == ed.measurement.root_task
    exopy_qtbot.wait_until(assert_selected)
Exemplo n.º 45
0
def test_settings_creation_dialog(prof_plugin, model_infos, exopy_qtbot,
                                  dialog_sleep):
    """Test the dialog dedicated to create new settings.

    """
    d = SettingsCreationDialog(plugin=prof_plugin, model_infos=model_infos,
                               existing=['false_settings2'])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    assert d.settings
    assert len(d._settings) == 3

    ws = d.central_widget().widgets()
    ws[0].selected_item = ws[0].items[1]
    ok = ws[-1]

    def assert_enabled():
        assert not ok.enabled
    exopy_qtbot.wait_until(assert_enabled)
    exopy_qtbot.wait(dialog_sleep)

    n = ws[-3]
    n.text = 'dummy'
    assert ok.enabled

    n.validator.validate('false_settings2')
    assert not ok.enabled

    n = ws[-3]
    n.text = 'dummy'
    ok.clicked = True
    assert d.settings.user_id == n.text
    assert d.result

    d2 = SettingsCreationDialog(plugin=prof_plugin, model_infos=model_infos,
                                existing=['false_settings2'])
    d2.show()
    wait_for_window_displayed(exopy_qtbot, d2)
    d2.central_widget().widgets()[-2].clicked = False  # Cancel button

    def assert_result():
        assert not d2.result
    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 46
0
def test_compiling_a_sequence_not_compiling(workspace, root, exopy_qtbot,
                                            dialog_sleep):
    """Test compiling that cannot compile as the sequence does not evaluate.

    """
    workbench = workspace.workbench
    ui = workbench.get_plugin('enaml.workbench.ui')
    ui.show_window()
    exopy_qtbot.wait(10 + dialog_sleep)

    root.external_vars = OrderedDict({'a': 1.5})

    pulse1 = Pulse(def_1='1.0', def_2='{a}')
    pulse2 = Pulse(def_1='{a + {b} + 1.0', def_2='3.0')
    pulse3 = Pulse(def_1='{4_start} - 0.5',
                   def_2='{4_start}+{4_duration}-0.5')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='3.0', def_2='0.5', def_mode='Start/Duration')

    sequence2 = BaseSequence(time_constrained=True,
                             def_1='{3_stop} + 0.5', def_2='6',
                             name='test')
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    add_children(sequence1, (pulse2, sequence2, pulse4))

    add_children(root, (pulse1, sequence1, pulse5))

    workspace.state.sequence = root

    dial = CompileDialog(workspace=workspace)
    dial.show()
    wait_for_window_displayed(exopy_qtbot, dial)
    exopy_qtbot.wait(dialog_sleep)

    comp_widget = dial.central_widget().widgets()[0]

    comp_widget.widgets()[-1].clicked = True

    def assert_exec():
        assert comp_widget.elapsed_time
        assert comp_widget.errors
        assert comp_widget.widgets()[-2].background == parse_color('red')
    exopy_qtbot.wait_until(assert_exec)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 47
0
def test_checks_display_not_warning_force_enqueue(exopy_qtbot, dialog_sleep):
    """Test displaying checks for a situation that do not allow enqueuing.

    """
    dial = ChecksDisplay(errors={'test': 'dummy', 'complex': {'rr': 'tt'}})

    dial.show()
    wait_for_window_displayed(exopy_qtbot, dial)
    exopy_qtbot.wait(dialog_sleep)

    assert dial.central_widget().widgets()[-1].text == 'Force enqueue'

    with handle_question(exopy_qtbot, 'yes'):
        dial.central_widget().widgets()[-1].clicked = True

    def assert_result():
        assert dial.result
    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 48
0
def test_checks_display_warning(exopy_qtbot, dialog_sleep):
    """Test displaying checks that allow enqueuing.

    """
    dial = ChecksDisplay(errors={'test': 'dummy', 'internal': {'rr': 'tt'}},
                         is_warning=True)

    dial.show()
    wait_for_window_displayed(exopy_qtbot, dial)
    exopy_qtbot.wait(dialog_sleep)

    assert dial.central_widget().widgets()[-1].text == 'Enqueue'

    dial.central_widget().widgets()[-1].clicked = True

    def assert_result():
        assert dial.result
    exopy_qtbot.wait_until(assert_result)
Exemplo n.º 49
0
def test_connection_creation_dialog(prof_plugin, model_infos, exopy_qtbot,
                                    dialog_sleep):
    """Test the dialog dedicated to create new connections.

    """
    d = ConnectionCreationDialog(plugin=prof_plugin,
                                 model_infos=model_infos,
                                 existing=['false_connection2'])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    assert d.connection
    assert len(d._connections) == 2

    ws = d.central_widget().widgets()
    ws[0].selected_item = ws[0].items[1]

    def assert_id():
        assert d.connection.declaration.id == 'false_connection3'

    exopy_qtbot.wait_until(assert_id)
    ws[-1].clicked = True  # Ok button

    def assert_result():
        assert d.result

    exopy_qtbot.wait_until(assert_result)
    exopy_qtbot.wait(dialog_sleep)

    d = ConnectionCreationDialog(plugin=prof_plugin,
                                 model_infos=model_infos,
                                 existing=['false_connection2'])
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    d.central_widget().widgets()[-2].clicked = True  # Cancel button

    def assert_result():
        assert not d.result

    exopy_qtbot.wait_until(assert_result)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 50
0
def test_browsing_dialog_instruments(exopy_qtbot, prof_plugin, dialog_sleep):
    """Test the browsing dialog page dedicated to explore the instruments.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    sel = nb.pages()[2].page_widget().widgets()[0]
    sel.use_series = False
    exopy_qtbot.wait(10)
    sel.model = prof_plugin._manufacturers.manufacturers[0].instruments[0]
    exopy_qtbot.wait(10 + dialog_sleep)

    def assert_widget():
        assert type(nb.pages()[0].page_widget().widgets()[1]) is not Container
    exopy_qtbot.wait_until(assert_widget)
Exemplo n.º 51
0
def test_profile_edition_dialog_ok(prof_plugin, dialog_sleep, exopy_qtbot,
                                   profile_infos):
    """Test the dialog used to edit a profile.

    """
    # XXX need to test model selection
    profile_infos.connections.clear()
    profile_infos.settings.clear()

    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    wait_for_window_displayed(exopy_qtbot, ed)
    exopy_qtbot.wait(dialog_sleep)

    ed_widgets = ed.central_widget().widgets()
    ed_widget = ed_widgets[0]

    nb = ed_widget.widgets()[5]
    c_page, s_page = nb.pages()

    # Add a connection
    with handle_dialog(exopy_qtbot, cls=ConnectionCreationDialog):
        c_page.page_widget().widgets()[2].clicked = True

    exopy_qtbot.wait(10 + dialog_sleep)

    # Add a settings
    with handle_dialog(exopy_qtbot, cls=SettingsCreationDialog):
        s_page.page_widget().widgets()[2].clicked = True

    exopy_qtbot.wait(10 + dialog_sleep)

    assert len(ed_widget.connections) == 1
    assert len(ed_widget.settings) == 1

    ed_widgets[-1].clicked = True

    def assert_cn_st():
        assert len(profile_infos.connections) == 1
        assert len(profile_infos.settings) == 1

    exopy_qtbot.wait_until(assert_cn_st)
Exemplo n.º 52
0
def test_browsing_dialog_instruments(exopy_qtbot, prof_plugin, dialog_sleep):
    """Test the browsing dialog page dedicated to explore the instruments.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    sel = nb.pages()[2].page_widget().widgets()[0]
    sel.use_series = False
    exopy_qtbot.wait(10)
    sel.model = prof_plugin._manufacturers.manufacturers[0].instruments[0]
    exopy_qtbot.wait(10 + dialog_sleep)

    def assert_widget():
        assert type(nb.pages()[0].page_widget().widgets()[1]) is not Container

    exopy_qtbot.wait_until(assert_widget)
Exemplo n.º 53
0
def test_sync_id(exopy_qtbot, edition_view, dialog_sleep):
    """Test the synchronisation between the measurement id and widget.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    meas = ed.measurement
    field = ed.widgets()[3]

    def assert_field_text():
        assert meas.id == field.text

    meas.id = '101'
    exopy_qtbot.wait_until(assert_field_text)

    field.text = '202'
    exopy_qtbot.wait_until(assert_field_text)
Exemplo n.º 54
0
def test_sync_name(exopy_qtbot, edition_view, dialog_sleep):
    """Test the synchronisation between the measurement name and widget.

    """
    edition_view.show()
    wait_for_window_displayed(exopy_qtbot, edition_view)
    exopy_qtbot.wait(dialog_sleep)

    ed = edition_view.widget.dock_widget().widgets()[0]
    meas = ed.measurement
    field = ed.widgets()[1]

    def assert_field_text():
        assert meas.name == field.text

    meas.name = '__dummy'
    exopy_qtbot.wait_until(assert_field_text)

    field.text = 'dummy__'
    exopy_qtbot.wait_until(assert_field_text)
Exemplo n.º 55
0
def test_profile_edition_dialog_ok(prof_plugin, dialog_sleep, exopy_qtbot,
                                   profile_infos):
    """Test the dialog used to edit a profile.

    """
    # XXX need to test model selection
    profile_infos.connections.clear()
    profile_infos.settings.clear()

    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    wait_for_window_displayed(exopy_qtbot, ed)
    exopy_qtbot.wait(dialog_sleep)

    ed_widgets = ed.central_widget().widgets()
    ed_widget = ed_widgets[0]

    nb = ed_widget.widgets()[5]
    c_page, s_page = nb.pages()

    # Add a connection
    with handle_dialog(exopy_qtbot, cls=ConnectionCreationDialog):
        c_page.page_widget().widgets()[2].clicked = True

    exopy_qtbot.wait(10 + dialog_sleep)

    # Add a settings
    with handle_dialog(exopy_qtbot, cls=SettingsCreationDialog):
        s_page.page_widget().widgets()[2].clicked = True

    exopy_qtbot.wait(10 + dialog_sleep)

    assert len(ed_widget.connections) == 1
    assert len(ed_widget.settings) == 1

    ed_widgets[-1].clicked = True

    def assert_cn_st():
        assert len(profile_infos.connections) == 1
        assert len(profile_infos.settings) == 1
    exopy_qtbot.wait_until(assert_cn_st)
Exemplo n.º 56
0
def test_ending_with_no_tools(measurement, exopy_qtbot, dialog_sleep):
    """Test adding/moving/removing tools.

    """
    for m in list(measurement.monitors):
        measurement.remove_tool('monitor', m)
    item = ToolsEditorDockItem(measurement=measurement)
    window = DockItemTestingWindow(widget=item)

    window.show()
    window.maximize()
    wait_for_window_displayed(exopy_qtbot, window)
    exopy_qtbot.wait(dialog_sleep)

    nb = item.dock_widget().widgets()[0]
    mon_ed = nb.pages()[1].page_widget().widgets()[0]

    # Add a tool
    def add_tool_1(bot, dial):
        widgets = dial.central_widget().widgets()
        widgets[0].selected_item = 'Dummy'
        bot.wait(10 + dialog_sleep)

    with handle_dialog(exopy_qtbot, 'accept', handler=add_tool_1):
        mon_ed.widgets()[-4].clicked = True

    assert 'dummy' in measurement.monitors

    # Move up and then down
    mon_ed.selected_id = 'dummy'
    assert not mon_ed.widgets()[-2].enabled

    assert not mon_ed.widgets()[-1].enabled

    # Remove dummy
    mon_ed.widgets()[-3].clicked = True

    def assert_removed():
        assert 'dummy' not in measurement.monitors
    exopy_qtbot.wait_until(assert_removed)
Exemplo n.º 57
0
def test_rule_selection_for_loading(text_monitor_workbench, exopy_qtbot,
                                    dialog_sleep):
    """Test using the dialog to select an existing config to load a task.

    """
    p = text_monitor_workbench.get_plugin(PLUGIN_ID)

    d = CreateRuleDialog(plugin=p)
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)

    page = d.central_widget().widgets()[0].pages()[0]
    page_content = page.page_widget().widgets()

    # Select rule config
    qlist = page_content[0]
    qlist.selected_item = qlist.items[-1]

    def assert_rule():
        assert page.rule == d.rule
    exopy_qtbot.wait_until(assert_rule)
    exopy_qtbot.wait(dialog_sleep)
Exemplo n.º 58
0
def test_browing_dialog_profiles_edit(exopy_qtbot, prof_plugin, dialog_sleep):
    """Test the browsing dialog page dedicated to explore the profiles.

    """
    d = BrowsingDialog(plugin=prof_plugin)
    nb = d.central_widget().widgets()[0]
    nb.selected_tab = 'profiles'
    d.show()
    wait_for_window_displayed(exopy_qtbot, d)
    exopy_qtbot.wait(dialog_sleep)

    c = nb.pages()[0].page_widget()
    btn = c.widgets()[-2]
    c.p_id = 'fp1'

    manu = prof_plugin._manufacturers._manufacturers['Dummy']
    model = manu._series['dumb']._models['002']

    def handle(bot, dial):
        dial.profile_infos.model = model

    with handle_dialog(exopy_qtbot, 'reject', handle,
                       cls=ProfileEditionDialog):
        btn.clicked = True

    assert prof_plugin._profiles['fp1'].model != model

    def handle(bot, dial):
        assert not dial.creation
        dial.profile_infos.model = model
        dial.central_widget().widgets()[0].sync()

    with handle_dialog(exopy_qtbot, 'accept', handle,
                       cls=ProfileEditionDialog):
        btn.clicked = True

    assert prof_plugin._profiles['fp1'].model == model
    assert (ConfigObj(prof_plugin._profiles['fp1'].path)['model_id'] ==
            'Dummy.dumb.002')