Esempio n. 1
0
def test_continuous_criteria_none(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    w.page(wizard.Page.Weights).collection = lambda: ['color', 'taste']
    qtbot.addWidget(w)
    w.show()
    advanced_radio = w.currentPage().layout().itemAt(1).widget()
    advanced_radio.setChecked(True)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'orange')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.ContinuousCriteriaPage

    # Test pages
    assert w.next_button.isEnabled() is True
    # Accept default, which is no continuous criteria
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.RatingPage
Esempio n. 2
0
    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.settings = settings.Settings(self)
        self.mad = mad.Mad(self)
        self.turnering = turnering.Turnering(self)
        self.tilmeld = tilmeld.Tilmeld(self)
        self.rapport = rapport.Rapport(self)

        self.turnering.dialog = TurneringDialog(self.turnering)
        self.ui.btnNewTurnering.clicked.connect(self.turnering.dialog.new)
        self.ui.btnEditTurnering.clicked.connect(self.turnering.dialog.edit)

        self.ui.btnTilmeld.clicked.connect(lambda: self.goto(1))
        self.ui.btnMad.clicked.connect(lambda: self.goto(2))
        self.ui.btnTurnering.clicked.connect(lambda: self.goto(3))
        self.ui.btnSettings.clicked.connect(lambda: self.goto(4))
        self.ui.btnRapport.clicked.connect(lambda: self.goto(5))
        self.ui.btnBack.clicked.connect(self.goto_menu)

        # Fix headers
        self.ui.tblTilmelding.horizontalHeader().setVisible(True)
        self.ui.tblMad.horizontalHeader().setVisible(True)

        self.goto_menu()
Esempio n. 3
0
def test_choices_wizard_page(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    qtbot.addWidget(w)
    w.show()
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.ChoicesPage

    # Test page
    abstract_multi_input_page_tester(qtbot, w, 'apple', 'orange', 'index')
    assert w.next_button.isEnabled() is True
Esempio n. 4
0
    def __init__(self, secret, url="http://127.0.0.1:3000", *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.secret = secret
        self.url = url

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.dorf.pressed.connect(self.play_dorf)
        self.ui.wald.pressed.connect(self.play_wald)
        self.ui.schmiede.pressed.connect(self.play_schmiede)
        self.ui.tempel.pressed.connect(self.play_tempel)
        self.ui.hoele.pressed.connect(self.play_hoele)
        self.ui.taverne.pressed.connect(self.play_taverne)
        self.ui.kampf.pressed.connect(self.play_kampf)
        self.ui.wald_nachts.pressed.connect(self.play_wald_nachts)
Esempio n. 5
0
def test_welcome_page_advanced(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    qtbot.addWidget(w)
    w.show()

    advanced_radio = w.currentPage().layout().itemAt(1).widget()
    advanced_radio.setChecked(True)  # mouse click doesn't work
    assert advanced_radio.isChecked() is True
    assert w.field('basic') is False

    assert w.next_button.isEnabled() is True
Esempio n. 6
0
def test_criteria_wizard_page(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    qtbot.addWidget(w)
    w.show()
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.CriteriaPage

    # Test page
    abstract_multi_input_page_tester(qtbot, w, 'taste', 'color', 'columns')
    assert w.next_button.isEnabled() is True
Esempio n. 7
0
def test_continuous_criteria_weights(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    ui.data_grid = Mock()
    w = wizard.Wizard(ui)
    w.page(wizard.Page.Weights).collection = lambda: ['color', 'taste']
    qtbot.addWidget(w)
    w.show()
    advanced_radio = w.currentPage().layout().itemAt(1).widget()
    advanced_radio.setChecked(True)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'orange')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.mouseClick(w.currentPage().yes, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'price')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'size')
    qtbot.mouseClick(w.currentPage().add_button, Qt.LeftButton)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.ContinuousCriteriaWeightsPage

    # Test pages
    abstract_slider_page_tester(qtbot, w)
    assert w.main_parent.matrix.df.loc['Weight', 'price'] == 4
    assert w.next_button.isEnabled() is True
Esempio n. 8
0
def test_weights_wizard_page_basic(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    qtbot.addWidget(w)
    w.show()
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.WeightsPage

    # Test page
    abstract_slider_page_tester(qtbot, w)
    assert w.main_parent.matrix.df.loc['Weight'][:-1][0] == 4
    assert w.next_button.isEnabled() is True
Esempio n. 9
0
    def drag_enter_event(event: QDragEnterEvent) -> None:
        data = event.mimeData()
        url = data.urls()[0]
        if url and url.isLocalFile() and url.fileName().endswith('.pdf'):
            event.acceptProposedAction()

    def drop_event(event: QDropEvent) -> None:
        data = event.mimeData()
        url = data.urls()[0]
        if url and url.isLocalFile() and url.fileName().endswith('.pdf'):
            line_edit.setText(url.toLocalFile())

    line_edit.dragEnterEvent = drag_enter_event
    line_edit.dropEvent = drop_event


if __name__ == '__main__':
    path_to_pdf = sys.argv[1] if len(sys.argv) > 1 else None
    poppler_path = '/usr/local/bin' if is_mac() else None

    appctxt = ApplicationContext()
    MainWindow = MainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    enable_file_drag(ui.lineEdit)
    if path_to_pdf and os.path.exists(path_to_pdf):
        MainWindow.set_path_to_pdf(path_to_pdf)
    MainWindow.show()
    sys.exit(appctxt.app.exec_())
Esempio n. 10
0
def test_value_score_wizard_page(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    ui.data_grid = Mock()
    w = wizard.Wizard(ui)
    w.page(wizard.Page.Weights).collection = lambda: ['color', 'taste']
    qtbot.addWidget(w)
    w.show()
    advanced_radio = w.currentPage().layout().itemAt(1).widget()
    advanced_radio.setChecked(True)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'orange')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.mouseClick(w.currentPage().yes, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'price')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'size')
    qtbot.mouseClick(w.currentPage().add_button, Qt.LeftButton)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.ValueScorePage

    # Test pages
    number_of_criteria = 2
    assert len(w.currentPage().value_spin_boxes.keys()) == number_of_criteria
    assert len(w.currentPage().score_spin_boxes.keys()) == number_of_criteria
    assert len(w.currentPage().vertical_layouts.keys()) == number_of_criteria

    number_of_choices = 2
    for spin_boxes in w.currentPage().value_spin_boxes.values():
        assert len(spin_boxes) == number_of_choices

    for spin_boxes in w.currentPage().score_spin_boxes.values():
        assert len(spin_boxes) == number_of_choices

    for vertical_layout in w.currentPage().vertical_layouts.values():
        # number_of_choices * form_layouts + one 'add pair' button
        assert vertical_layout.count() == number_of_choices + 1

        for i in range(vertical_layout.count() - 1):
            form_layout = vertical_layout.itemAt(i)
            # Each form has a label and an inner grid
            assert form_layout.count() == 2

            inner_grid = form_layout.itemAt(1)
            # Each inner grid has two spin boxes, a label, and a delete button
            assert inner_grid.count() == 4

    # 0: First row
    w.currentPage().value_spin_boxes['price'][0].setValue(1)
    assert 'price' not in w.main_parent.matrix.value_score_df.columns
    w.currentPage().score_spin_boxes['price'][0].setValue(10)
    assert 'price' in w.main_parent.matrix.value_score_df.columns
    assert w.main_parent.matrix.value_score_df.loc[0, 'price'] == 1
    assert w.main_parent.matrix.value_score_df.loc[0, 'price_score'] == 10

    w.currentPage().value_spin_boxes['price'][1].setValue(5)
    qtbot.mouseClick(w.currentPage().score_spin_boxes['price'][1],
                     Qt.LeftButton)
    qtbot.keyClick(w.currentPage().score_spin_boxes['price'][1], Qt.Key_Up)

    assert w.main_parent.matrix.value_score_df.loc[1, 'price'] == 5
    assert w.main_parent.matrix.value_score_df.loc[1, 'price_score'] == 1

    # Changing values and scores of a row doesn't affect other rows
    assert w.main_parent.matrix.value_score_df.loc[0, 'price'] == 1
    assert w.main_parent.matrix.value_score_df.loc[0, 'price_score'] == 10

    w.currentPage().value_spin_boxes['size'][0].setValue(7)
    w.currentPage().score_spin_boxes['size'][0].setValue(1)
    assert w.main_parent.matrix.value_score_df.loc[0, 'size'] == 7
    assert w.main_parent.matrix.value_score_df.loc[0, 'size_score'] == 1

    w.currentPage().value_spin_boxes['size'][1].setValue(6)
    w.currentPage().score_spin_boxes['size'][1].setValue(5)
    assert w.main_parent.matrix.value_score_df.loc[1, 'size'] == 6
    assert w.main_parent.matrix.value_score_df.loc[1, 'size_score'] == 5

    # Changing values and scores of a criterion doesn't affect other criteria
    assert w.main_parent.matrix.value_score_df.loc[0, 'price'] == 1
    assert w.main_parent.matrix.value_score_df.loc[0, 'price_score'] == 10

    assert w.next_button.isEnabled() is True
Esempio n. 11
0
def test_continuous_criteria_wizard_page(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    ui.data_grid = Mock()
    w = wizard.Wizard(ui)
    w.page(wizard.Page.Weights).collection = lambda: ['color', 'taste']
    qtbot.addWidget(w)
    w.show()
    advanced_radio = w.currentPage().layout().itemAt(1).widget()
    advanced_radio.setChecked(True)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'orange')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.ContinuousCriteriaPage

    # Test pages
    assert w.field('yes') is False
    assert w.currentPage().line_edit.isEnabled() is False
    assert w.currentPage().list_widget.isEnabled() is False
    assert w.currentPage().add_button.isEnabled() is False
    qtbot.mouseClick(w.currentPage().yes, Qt.LeftButton)
    assert w.field('yes') is True
    assert w.currentPage().line_edit.isEnabled() is True
    assert w.currentPage().list_widget.isEnabled() is True
    assert w.currentPage().add_button.isEnabled() is True

    # Kind of duplicated from abstract_multi_input_page_tester()
    qtbot.keyClicks(w.currentPage().line_edit, 'price')
    assert w.currentPage().line_edit.text() == 'price'
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    assert w.currentPage().line_edit.text() == ''
    assert w.currentPage().list_widget.item(0).text() == 'price'

    qtbot.keyClicks(w.currentPage().line_edit, 'size')
    qtbot.mouseClick(w.currentPage().add_button, Qt.LeftButton)
    assert w.currentPage().line_edit.text() == ''
    assert w.currentPage().list_widget.item(1).text() == 'size'
    assert w.currentPage().list_widget.count() == 2

    assert 'price' in w.main_parent.matrix.df.columns
    assert 'size' in w.main_parent.matrix.df.columns

    w.currentPage().list_widget.setCurrentRow(1)
    qtbot.mouseClick(w.currentPage().delete_button, Qt.LeftButton)
    assert w.currentPage().list_widget.count() == 1
    assert w.currentPage().list_widget.item(0).text() == 'price'

    assert 'price' in w.main_parent.matrix.df.columns
    assert 'size' not in w.main_parent.matrix.df.columns

    assert w.next_button.isEnabled() is True
Esempio n. 12
0
def test_ratings_basic(qtbot):
    # Setup
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.matrix = Matrix()
    w = wizard.Wizard(ui)
    w.page(wizard.Page.Weights).collection = lambda: ['color', 'taste']
    qtbot.addWidget(w)
    w.show()
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'apple')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'orange')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    qtbot.keyClicks(w.currentPage().line_edit, 'color')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.keyClicks(w.currentPage().line_edit, 'taste')
    qtbot.keyClick(w.currentPage().line_edit, Qt.Key_Enter)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    w.currentPage().spin_boxes[0].setValue(4)
    w.currentPage().spin_boxes[1].setValue(7)
    qtbot.mouseClick(w.next_button, Qt.LeftButton)
    assert type(w.currentPage()) == wizard.RatingPage

    # Test page
    number_of_choices = 2
    assert len(w.currentPage().sliders.keys()) == number_of_choices
    assert len(w.currentPage().spin_boxes.keys()) == number_of_choices

    number_of_criteria = 2
    for choice in ('apple', 'orange'):
        assert len(w.currentPage().sliders[choice]) == number_of_criteria
        assert len(w.currentPage().spin_boxes[choice]) == number_of_criteria

    for choice in ('apple', 'orange'):
        for row in (0, 1):
            w.currentPage().spin_boxes[choice][row].setValue(5)
            # Spin boxes and sliders have synchronized values
            assert (w.currentPage().spin_boxes[choice][row].value() ==
                    w.currentPage().sliders[choice][row].value() == 5)

            # Using up-arrow key to change value
            qtbot.mouseClick(w.currentPage().spin_boxes[choice][row],
                             Qt.LeftButton)
            qtbot.keyClick(w.currentPage().spin_boxes[choice][row], Qt.Key_Up)
            assert (w.currentPage().spin_boxes[choice][row].value() ==
                    w.currentPage().sliders[choice][row].value() == 6)

    # First value is empty
    assert (w.main_parent.matrix.df.loc['Weight'][:-1] == [4, 7]).all()
    assert (w.main_parent.matrix.df.loc[:, 'Percentage'][1:] == [60, 60]).all()

    w.currentPage().spin_boxes['apple'][0].setValue(3)
    assert w.main_parent.matrix.df.loc[:, 'Percentage'][1] == 49.09090909090909

    w.currentPage().spin_boxes['apple'][1].setValue(7)
    assert w.main_parent.matrix.df.loc[:, 'Percentage'][1] == 55.45454545454545

    w.currentPage().spin_boxes['orange'][0].setValue(4)
    assert w.main_parent.matrix.df.loc[:, 'Percentage'][2] == 52.72727272727272

    w.currentPage().spin_boxes['orange'][1].setValue(7)
    assert w.main_parent.matrix.df.loc[:, 'Percentage'][2] == 59.09090909090909

    assert w.next_button.isEnabled() is True