Beispiel #1
0
def test_profile_edition_dialog_cancel(prof_plugin, process_and_sleep,
                                       profile_infos):
    """Test the dialog used to edit a profile.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    process_and_sleep()

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

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

    # Delete a connection and open valiadtion window
    c_page.page_widget().widgets()[3].clicked = True
    c_page.page_widget().widgets()[4].clicked = True

    # Delete a settings
    s_page.page_widget().widgets()[4].clicked = True

    process_and_sleep()
    w = ed_widget._validator

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

    ed_widgets[-2].clicked = True
    process_app_events()
    assert not ed.visible and not w.visible

    assert len(profile_infos.connections) == 3
    assert len(profile_infos.settings) == 3
def test_profile_edition_dialog_cancel(prof_plugin, process_and_sleep,
                                       profile_infos):
    """Test the dialog used to edit a profile.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    process_and_sleep()

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

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

    # Delete a connection and open valiadtion window
    c_page.page_widget().widgets()[3].clicked = True
    c_page.page_widget().widgets()[4].clicked = True

    # Delete a settings
    s_page.page_widget().widgets()[4].clicked = True

    process_and_sleep()
    w = ed_widget._validator

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

    ed_widgets[-2].clicked = True
    process_app_events()
    assert not ed.visible and not w.visible

    assert len(profile_infos.connections) == 3
    assert len(profile_infos.settings) == 3
def test_connection_validation_window(prof_plugin, process_and_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()
    process_and_sleep()
    w = ConnectionValidationWindow(editor=ed.central_widget().widgets()[0])
    w.show()
    process_and_sleep()

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

    widgets[-1].clicked = True
    process_app_events()
Beispiel #4
0
def test_profile_edition_dialog_ok(prof_plugin, process_and_sleep,
                                   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()
    process_and_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(cls=ConnectionCreationDialog):
        c_page.page_widget().widgets()[2].clicked = True

    process_and_sleep()

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

    process_and_sleep()

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

    ed_widgets[-1].clicked = True
    process_app_events()

    assert len(profile_infos.connections) == 1
    assert len(profile_infos.settings) == 1
def test_profile_edition_dialog_ok(prof_plugin, process_and_sleep,
                                   profile_infos):
    """Test the dialog used to edit a profile.

    """
    profile_infos.connections.clear()
    profile_infos.settings.clear()

    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    process_and_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(cls=ConnectionCreationDialog):
        c_page.page_widget().widgets()[2].clicked = True

    process_and_sleep()

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

    process_and_sleep()

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

    ed_widgets[-1].clicked = True
    process_app_events()

    assert len(profile_infos.connections) == 1
    assert len(profile_infos.settings) == 1
Beispiel #6
0
def test_connection_validation_window(prof_plugin, process_and_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()
    process_and_sleep()
    w = ConnectionValidationWindow(editor=ed.central_widget().widgets()[0])
    w.show()
    process_and_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
    process_app_events()
def test_rename_settings_popup(prof_plugin, profile_infos, process_and_sleep):
    """Test the popup used to rename a settings.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    process_and_sleep()

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

    nb = ed_widget.widgets()[5]
    nb.selected_tab = 'settings'
    process_and_sleep()
    c_page, s_page = nb.pages()

    # Open the renaming popup.
    s_page.page_widget().widgets()[3].clicked = True

    # Get the popup.
    assert len(RenameSettingsPopup.popup_views) == 1
    p = RenameSettingsPopup.popup_views[0]
    settings = p.settings
    ws = p.central_widget().widgets()
    ws[1].text = ''
    process_and_sleep()
    assert not ws[-1].enabled

    ws[1].text = ed_widget.settings[1].name
    ws[1].validator.validate(ed_widget.settings[1].name)
    assert not ws[-1].enabled

    ws[1].text = 'dummy'
    ws[1].validator.validate('dummy')
    process_and_sleep()
    assert ws[-1].enabled

    ws[-1].clicked = True
    process_and_sleep()

    assert settings.name == 'dummy'

    i = 0
    while i < 10 and len(RenameSettingsPopup.popup_views) != 0:
        process_app_events()
        sleep(0.1)

    # Open a new popup
    s_page.page_widget().widgets()[3].clicked = True

    assert len(RenameSettingsPopup.popup_views) == 1
    p = RenameSettingsPopup.popup_views[0]
    ws = p.central_widget().widgets()

    ws[1].text = 'dummy2'
    process_and_sleep()
    assert ws[-1].enabled

    ws[-2].clicked = True
    process_and_sleep()

    assert settings.name == 'dummy'
Beispiel #8
0
def test_rename_settings_popup(prof_plugin, profile_infos, process_and_sleep):
    """Test the popup used to rename a settings.

    """
    ed = ProfileEditionDialog(plugin=prof_plugin, profile_infos=profile_infos)
    ed.show()
    process_and_sleep()

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

    nb = ed_widget.widgets()[5]
    nb.selected_tab = 'settings'
    process_and_sleep()
    c_page, s_page = nb.pages()

    # Open the renaming popup.
    s_page.page_widget().widgets()[3].clicked = True

    # Get the popup.
    assert len(RenameSettingsPopup.popup_views) == 1
    p = RenameSettingsPopup.popup_views[0]
    settings = p.settings
    ws = p.central_widget().widgets()
    ws[1].text = ''
    process_and_sleep()
    assert not ws[-1].enabled

    ws[1].text = ed_widget.settings[1].name
    ws[1].validator.validate(ed_widget.settings[1].name)
    assert not ws[-1].enabled

    ws[1].text = 'dummy'
    ws[1].validator.validate('dummy')
    process_and_sleep()
    assert ws[-1].enabled

    ws[-1].clicked = True
    process_and_sleep()

    assert settings.user_id == 'dummy'

    i = 0
    while i < 10 and len(RenameSettingsPopup.popup_views) != 0:
        process_app_events()
        sleep(0.1)

    # Open a new popup
    s_page.page_widget().widgets()[3].clicked = True

    assert len(RenameSettingsPopup.popup_views) == 1
    p = RenameSettingsPopup.popup_views[0]
    ws = p.central_widget().widgets()

    ws[1].text = 'dummy2'
    process_and_sleep()
    assert ws[-1].enabled

    ws[-2].clicked = True
    process_and_sleep()

    assert settings.user_id == 'dummy'