Esempio n. 1
0
def test_editor_widget(windows, task, dialog_sleep):
    """That the interaction with the editor widget makes sense.

    """
    dialog_sleep = dialog_sleep or 1

    def get_task_widget(editor):
        return editor.page_widget().widgets()[0].scroll_widget()

    def get_menu(task_widget, widget_index):
        flow_area = task_widget.widgets()[0]
        flow_item = flow_area.flow_items()[widget_index]
        menu = flow_item.flow_widget().widgets()[0].children[0]
        return menu

    task_with_exs = task.children[1].children[1].children[0]

    editor = DatabaseAccessEditor(declaration=Editor(id='ecpy.database'),
                                  selected_task=task)
    window = PageTestingWindow(widget=editor)
    window.show()
    process_app_events()
    sleep(dialog_sleep)

    r_widget = get_task_widget(editor)
    flow_area = r_widget.children[0]
    # Check that there is no contextual menu attached.
    assert len(flow_area.children[0].children[0].children) == 1

    # Add an access exception to the lowest level.
    editor.selected_task = task.children[1].children[1]
    process_app_events()
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    add_ex_action = get_menu(widget, 0).items()[0]
    add_ex_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 1
    sleep(dialog_sleep)

    # Move the exception up
    editor.selected_task = task.children[1]
    process_app_events()
    assert len(flow_area.flow_items()) == 4
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    menu = get_menu(widget, -1)
    assert len(menu.items()) == 2  # Check that both actions are there.
    move_up_action = menu.items()[0]
    move_up_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 2
    sleep(dialog_sleep)

    # Move the exception down
    editor.selected_task = task
    process_app_events()
    assert len(flow_area.flow_items()) == 3
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    menu = get_menu(widget, -1)
    assert len(menu.items()) == 1  # Check that only one action is there.
    move_down_action = menu.items()[0]
    move_down_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 1
    sleep(dialog_sleep)

    # Move the exception down (it disappears)
    editor.selected_task = task.children[1]
    process_app_events()
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    assert len(flow_area.flow_items()) == 4

    menu = get_menu(widget, -1)
    move_down_action = menu.items()[1]
    move_down_action.triggered = True
    process_app_events()
    assert not task_with_exs.access_exs
    sleep(dialog_sleep)

    editor.selected_task = task
    process_app_events()
    sleep(dialog_sleep)
Esempio n. 2
0
def test_editor_widget(windows, task, dialog_sleep):
    """That the interaction with the editor widget makes sense.

    """
    dialog_sleep = dialog_sleep or 1

    def get_task_widget(editor):
        return editor.page_widget().widgets()[0].scroll_widget()

    def get_menu(task_widget, widget_index):
        flow_area = task_widget.widgets()[0]
        flow_item = flow_area.flow_items()[widget_index]
        menu = flow_item.flow_widget().widgets()[0].children[0]
        return menu

    task_with_exs = task.children[1].children[1].children[0]

    editor = DatabaseAccessEditor(declaration=Editor(id='ecpy.database'),
                                  selected_task=task)
    window = PageTestingWindow(widget=editor)
    window.show()
    process_app_events()
    sleep(dialog_sleep)

    r_widget = get_task_widget(editor)
    flow_area = r_widget.children[0]
    # Check that there is no contextual menu attached.
    assert len(flow_area.children[0].children[0].children) == 1

    # Add an access exception to the lowest level.
    editor.selected_task = task.children[1].children[1]
    process_app_events()
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    add_ex_action = get_menu(widget, 0).items()[0]
    add_ex_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 1
    sleep(dialog_sleep)

    # Move the exception up
    editor.selected_task = task.children[1]
    process_app_events()
    assert len(flow_area.flow_items()) == 4
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    menu = get_menu(widget, -1)
    assert len(menu.items()) == 2  # Check that both actions are there.
    move_up_action = menu.items()[0]
    move_up_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 2
    sleep(dialog_sleep)

    # Move the exception down
    editor.selected_task = task
    process_app_events()
    assert len(flow_area.flow_items()) == 3
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    menu = get_menu(widget, -1)
    assert len(menu.items()) == 1  # Check that only one action is there.
    move_down_action = menu.items()[0]
    move_down_action.triggered = True
    process_app_events()
    assert task_with_exs.access_exs['t'] == 1
    sleep(dialog_sleep)

    # Move the exception down (it disappears)
    editor.selected_task = task.children[1]
    process_app_events()
    sleep(dialog_sleep)

    widget = get_task_widget(editor)
    flow_area = widget.children[0]
    assert len(flow_area.flow_items()) == 4

    menu = get_menu(widget, -1)
    move_down_action = menu.items()[1]
    move_down_action.triggered = True
    process_app_events()
    assert not task_with_exs.access_exs
    sleep(dialog_sleep)

    editor.selected_task = task
    process_app_events()
    sleep(dialog_sleep)
def test_execution_editor_widget(windows, task, dialog_sleep):
    """Test the behavior of the execution editor widget.

    """
    dialog_sleep = dialog_sleep or 1
    task.children[1].children[0].parallel = {}

    def get_task_widget(editor):
        return editor.page_widget().widgets()[0].scroll_widget().widgets()[0]

    editor = ExecutionEditor(declaration=Editor(id='ecpy.execution_editor'),
                             selected_task=task)
    window = PageTestingWindow(widget=editor)
    window.show()
    process_app_events()
    sleep(dialog_sleep)

    ctask = task.children[1]
    editor.selected_task = ctask
    process_app_events()
    sleep(dialog_sleep)

    ced = get_task_widget(editor)
    ced.widgets()[0].checked = not ctask.stoppable
    process_app_events()
    assert ced.widgets()[0].checked == ctask.stoppable
    sleep(dialog_sleep)

    ctask.parallel['pool'] = 'test_'
    ced.widgets()[1].checked = True
    process_app_events()
    assert 'test_' in editor.pool_model.pools
    sleep(dialog_sleep)

    ced.widgets()[3].checked = False
    process_app_events()
    sleep(dialog_sleep)
    ctask.wait['no_wait'] = ['test2']
    ced.widgets()[3].checked = True
    process_app_events()
    assert 'test2' in editor.pool_model.pools
    sleep(dialog_sleep)

    ced.widgets()[2].selected = 'test2'
    process_app_events()
    assert 'test' not in editor.pool_model.pools
    sleep(dialog_sleep)

    def get_popup_content(parent):
        return parent.children[-1].central_widget().widgets()

    ced.widgets()[2].children[0].children[0].triggered = True
    process_app_events()
    sleep(dialog_sleep)
    process_app_events()  # So that the popup shows correctly
    popup_content = get_popup_content(ced.widgets()[2])
    popup_content[0].text = 'test3'
    popup_content[1].clicked = True
    process_app_events()
    assert 'test3' in editor.pool_model.pools
    sleep(dialog_sleep)
    process_app_events()  # So that the popup is closed correctly

    ced.widgets()[2].children[0].children[0].triggered = True
    process_app_events()
    sleep(dialog_sleep)
    process_app_events()  # So that the popup shows correctly
    popup_content = get_popup_content(ced.widgets()[2])
    popup_content[0].text = 'test4'
    popup_content[2].clicked = True
    process_app_events()
    assert 'test4' not in editor.pool_model.pools
    sleep(dialog_sleep)
    process_app_events()  # So that the popup is closed correctly

    assert ced.widgets()[4].checked is False
    ced.widgets()[4].checked = True
    process_app_events()
    assert 'wait' in ctask.wait and 'no_wait' not in ctask.wait
    sleep(dialog_sleep)

    ced.widgets()[7].clicked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content = get_popup_content(ced.widgets()[7])
    check_box = popup_content[0].scroll_widget().widgets()[1]
    assert not check_box.checked
    check_box.checked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content[-2].clicked = True
    process_app_events()
    assert 'test3' in ctask.wait['wait']
    sleep(dialog_sleep)

    ced.widgets()[7].clicked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content = get_popup_content(ced.widgets()[7])
    check_box = popup_content[0].scroll_widget().widgets()[2]
    assert not check_box.checked
    check_box.checked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content[-1].clicked = True
    process_app_events()
    assert 'test_' not in ctask.wait['wait']
    sleep(dialog_sleep)

    editor.selected_task = task
    task.remove_child_task(1)
    process_app_events()
    assert ctask not in editor._cache
    sleep(dialog_sleep)

    editor.ended = True
Esempio n. 4
0
def test_execution_editor_widget(windows, task, dialog_sleep):
    """Test the behavior of the execution editor widget.

    """
    dialog_sleep = dialog_sleep or 1
    task.children[1].children[0].parallel = {}

    def get_task_widget(editor):
        return editor.page_widget().widgets()[0].scroll_widget().widgets()[0]

    editor = ExecutionEditor(declaration=Editor(id="ecpy.execution_editor"), selected_task=task)
    window = PageTestingWindow(widget=editor)
    window.show()
    process_app_events()
    sleep(dialog_sleep)

    ctask = task.children[1]
    editor.selected_task = ctask
    process_app_events()
    sleep(dialog_sleep)

    ced = get_task_widget(editor)
    ced.widgets()[0].checked = not ctask.stoppable
    process_app_events()
    assert ced.widgets()[0].checked == ctask.stoppable
    sleep(dialog_sleep)

    ctask.parallel["pool"] = "test_"
    ced.widgets()[1].checked = True
    process_app_events()
    assert "test_" in editor.pool_model.pools
    sleep(dialog_sleep)

    ced.widgets()[3].checked = False
    process_app_events()
    sleep(dialog_sleep)
    ctask.wait["no_wait"] = ["test2"]
    ced.widgets()[3].checked = True
    process_app_events()
    assert "test2" in editor.pool_model.pools
    sleep(dialog_sleep)

    ced.widgets()[2].selected = "test2"
    process_app_events()
    assert "test" not in editor.pool_model.pools
    sleep(dialog_sleep)

    def get_popup_content(parent):
        return parent.children[-1].central_widget().widgets()

    ced.widgets()[2].children[0].children[0].triggered = True
    process_app_events()
    sleep(dialog_sleep)
    process_app_events()  # So that the popup shows correctly
    popup_content = get_popup_content(ced.widgets()[2])
    popup_content[0].text = "test3"
    popup_content[1].clicked = True
    process_app_events()
    assert "test3" in editor.pool_model.pools
    sleep(dialog_sleep)
    process_app_events()  # So that the popup is closed correctly

    ced.widgets()[2].children[0].children[0].triggered = True
    process_app_events()
    sleep(dialog_sleep)
    process_app_events()  # So that the popup shows correctly
    popup_content = get_popup_content(ced.widgets()[2])
    popup_content[0].text = "test4"
    popup_content[2].clicked = True
    process_app_events()
    assert "test4" not in editor.pool_model.pools
    sleep(dialog_sleep)
    process_app_events()  # So that the popup is closed correctly

    assert ced.widgets()[4].checked is False
    ced.widgets()[4].checked = True
    process_app_events()
    assert "wait" in ctask.wait and "no_wait" not in ctask.wait
    sleep(dialog_sleep)

    ced.widgets()[7].clicked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content = get_popup_content(ced.widgets()[7])
    check_box = popup_content[0].scroll_widget().widgets()[1]
    assert not check_box.checked
    check_box.checked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content[-2].clicked = True
    process_app_events()
    assert "test3" in ctask.wait["wait"]
    sleep(dialog_sleep)

    ced.widgets()[7].clicked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content = get_popup_content(ced.widgets()[7])
    check_box = popup_content[0].scroll_widget().widgets()[2]
    assert not check_box.checked
    check_box.checked = True
    process_app_events()
    sleep(dialog_sleep)
    popup_content[-1].clicked = True
    process_app_events()
    assert "test_" not in ctask.wait["wait"]
    sleep(dialog_sleep)

    editor.selected_task = task
    task.remove_child_task(1)
    process_app_events()
    assert ctask not in editor._cache
    sleep(dialog_sleep)

    editor.ended = True