def test_prize_alerts(qtbot: qtbot.QtBot, mocker: MockerFixture):
    """Ensures that all prize alerts are displayed with the correct text"""
    test_import_prizes(qtbot, mocker)

    raffle.restart()

    ticket_numbers = list(range(1, 226))
    shuffle(ticket_numbers)
    prize_alert_count = 0
    for i, ticket_number in enumerate(ticket_numbers):
        qtbot.mouseClick(
            gui_manager.window_list[0].ticket_labels[ticket_number - 1],
            Qt.LeftButton)
        QApplication.processEvents()
        sleep(0.05)

        # If a prize alert is next...
        if raffle.get_prize_from_number(i + 2) is not None:
            # Ensure a prize alert is shown
            assert isinstance(gui_manager.window_list[-1], PrizeAlert)
            qtbot.addWidget(gui_manager.window_list[-1])
            prize_alert_count += 1

            # Ensure the text is correct
            next_prize = raffle.get_prize_from_number(i + 2)
            assert next_prize.description == gui_manager.window_list[
                -1].prize_description.text()
            qtbot.mouseClick(gui_manager.window_list[-1], Qt.LeftButton)
            qtbot.waitUntil(
                lambda: not gui_manager.window_list[-1].isVisible())

            # Force gui manager to do housekeeping
            gui_manager.create_window(WindowType.INVALID)

    assert len(raffle.prizes) == prize_alert_count
예제 #2
0
def test_sys_argv_clear(ipyconsole, qtbot):
    shell = ipyconsole.get_current_shellwidget()
    client = ipyconsole.get_current_client()

    qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=6000)
    shell.execute('import sys; A = sys.argv')
    argv = shell.get_value("A")
    assert argv == ['']
예제 #3
0
def test_matplotlib_preview(qtbot):
    testdata = os.path.join(os.path.dirname(__file__), 'testdata', 'sample')
    otfdir = os.path.join(os.path.dirname(__file__), 'testdata', 'otfs')
    APP = QtWidgets.QApplication([])
    mainGUI = main_GUI()
    mainGUI.loadProgramDefaults()
    mainGUI.setOTFdirPath(otfdir)
    assert mainGUI.listbox.rowCount() == 0
    mainGUI.listbox.addPath(testdata)
    assert mainGUI.listbox.rowCount() == 1

    def preview_exists():
        assert len(mainGUI.spimwins)
    mainGUI.prevBackendMatplotlibRadio.setChecked(True)
    qtbot.mouseClick(mainGUI.previewButton, QtCore.Qt.LeftButton)
    qtbot.waitUntil(preview_exists, timeout=10000)
    mainGUI.close_all_previews()
    assert len(mainGUI.spimwins) == 0
    mainGUI.quitProgram(save=False)