Exemplo n.º 1
0
def test_should_preload_info(qtbot):
    with requests_mock.Mocker() as m:
        url = 'http://localhost:8080/cc.xml'
        m.get(url, text=fake_content())
        conf = ConfigBuilder().server(url, {
            "excludes/%s" % url: ['cleanup-artifacts-B'],
            "timezone/%s" % url: 'US/Eastern',
        }).build()

        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)
        qtbot.mouseClick(dialog.ui.loadUrlButton, QtCore.Qt.LeftButton)

        qtbot.waitUntil(lambda: dialog.ui.projectsList.model() is not None)
        model = dialog.ui.projectsList.model()

        assert model.item(0, 0).hasChildren()
        assert model.item(0, 0).child(0, 0).isCheckable()
        assert model.item(0, 0).child(0, 0).text() == "cleanup-artifacts-B"
        assert model.item(0, 0).child(0, 0).data(Qt.CheckStateRole) == Qt.Unchecked

        def timezone():
            assert dialog.ui.timezoneList.count() > 100
            assert dialog.ui.timezoneList.currentText() == 'US/Eastern'

        qtbot.waitUntil(timezone)
Exemplo n.º 2
0
def test_should_exclude_projects(qtbot):
    with requests_mock.Mocker() as m:
        url = 'http://localhost:8080/cc.xml'
        m.get(url, text=fake_content())
        conf = ConfigBuilder().server(url).build()
        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)
        qtbot.mouseClick(dialog.ui.loadUrlButton, QtCore.Qt.LeftButton)

        qtbot.waitUntil(lambda: dialog.ui.projectsList.model() is not None)
        model = dialog.ui.projectsList.model()

        model.item(0, 0).child(0, 0).setCheckState(QtCore.Qt.Unchecked)

        server_config = dialog.get_server_config()
        assert [str(s) for s in server_config.excluded_projects] == ['cleanup-artifacts-B']
Exemplo n.º 3
0
def test_should_save_restore_config(qtbot):
    with requests_mock.Mocker() as m:
        url = 'http://localhost:8080/cc.xml'
        m.get(url, text=fake_content())
        conf = ConfigBuilder().server(url).build()
        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)
        qtbot.mouseClick(dialog.ui.loadUrlButton, QtCore.Qt.LeftButton)

        qtbot.waitUntil(lambda: dialog.ui.projectsList.model() is not None)
        server_config = dialog.get_server_config()

        conf.save_server_config(server_config)
        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)
Exemplo n.º 4
0
def test_should_show_configured_urls(qtbot):
    with requests_mock.Mocker() as m:
        url = 'http://localhost:8080/cc.xml'
        m.get(url, text=fake_content())
        conf = ConfigBuilder().server(url).build()
        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)
        qtbot.mouseClick(dialog.ui.loadUrlButton, QtCore.Qt.LeftButton)

        qtbot.waitUntil(lambda: dialog.ui.projectsList.model() is not None)
        model = dialog.ui.projectsList.model()
        assert model.item(0, 0).hasChildren()
        assert model.item(0, 0).child(0, 0).isCheckable()
        assert model.item(0, 0).child(0, 0).data(Qt.CheckStateRole) == Qt.Checked
        assert model.item(0, 0).child(0, 0).text() == "cleanup-artifacts-B"

        assert dialog.ui.timezoneList.currentText() == 'None'
Exemplo n.º 5
0
def test_should_disable_authentication_if_keystore_is_unavailable(qtbot, mocker):
    m = mocker.patch.object(Keystore, 'isAvailable',
                            return_value=False)
    with requests_mock.Mocker() as r:
        url = 'http://localhost:8080/cc.xml'
        r.get(url, text=fake_content())

        conf = ConfigBuilder().server(url).build()
        dialog = ServerConfigurationDialog(url, conf)
        dialog.show()
        qtbot.addWidget(dialog)

        def alert_shown():
            assert not dialog.ui.username.isEnabled()
            assert not dialog.ui.password.isEnabled()
            assert dialog.ui.authenticationSettings.title() == 'Authentication (keyring dependency missing)'

        qtbot.wait_until(alert_shown)
Exemplo n.º 6
0
def test_should_consolidate_build_status(qtbot):
    with requests_mock.Mocker() as m:
        url = 'http://localhost:8080/cc.xml'
        m.get(url, text=fake_content())
        keyring.set_keyring(FakeKeyring())
        parent = QWidget()
        conf = ConfigBuilder().server(url).build()
        b = BuildNotify(parent, conf, 10)
        qtbot.addWidget(b.app)
        parent.show()

        qtbot.waitUntil(lambda: hasattr(b, 'app_ui'))

        def projects_loaded():
            assert len([
                str(a.text()) for a in b.app_ui.app_menu.menu.actions()
            ]) == 11

        if QSystemTrayIcon.isSystemTrayAvailable():
            qtbot.waitUntil(lambda: re.compile("Last checked.*").match(
                b.app_ui.tray.toolTip()) is not None,
                            timeout=5000)
            qtbot.waitUntil(projects_loaded)