Beispiel #1
0
def test_gui_iter_num(monkeypatch, tmpdir, qtbot, patch_enkf_main):
    # won't run simulations so we mock it and test whether "iter_num" is in arguments
    def _assert_iter_in_args(panel):
        assert panel.getSimulationArguments().iter_num == 10

    args_mock = Mock()
    type(args_mock).config = PropertyMock(return_value="config.ert")

    monkeypatch.setattr(
        ert_gui.simulation.simulation_panel.SimulationPanel,
        "runSimulation",
        _assert_iter_in_args,
    )

    notifier = ErtNotifier(args_mock.config)
    gui = _start_window(patch_enkf_main, notifier, args_mock)
    qtbot.addWidget(gui)

    sim_mode = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_mode")
    qtbot.keyClick(sim_mode, Qt.Key_Down)

    sim_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_panel")

    ensemble_panel = gui.findChild(qtpy.QtWidgets.QWidget,
                                   name="Ensemble_experiment_panel")
    # simulate entering number 10 as iter_num
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Backspace)
    qtbot.keyClicks(ensemble_panel._iter_field, "10")
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Enter)

    start_simulation = gui.findChild(qtpy.QtWidgets.QWidget,
                                     name="start_simulation")
    qtbot.mouseClick(start_simulation, Qt.LeftButton)
    assert sim_panel.getSimulationArguments().iter_num == 10
Beispiel #2
0
def test_gui_load(monkeypatch, tmpdir, qtbot, patch_enkf_main):
    args_mock = Mock()
    type(args_mock).config = PropertyMock(return_value="config.ert")

    gui = _start_window(patch_enkf_main, args_mock)
    qtbot.addWidget(gui)

    sim_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_panel")
    single_run_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Single_test_run_panel")
    assert sim_panel.getCurrentSimulationModel() == single_run_panel.getSimulationModel()

    sim_mode = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_mode")
    qtbot.keyClick(sim_mode, Qt.Key_Down)

    ensamble_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Ensemble_experiment_panel")
    assert sim_panel.getCurrentSimulationModel() == ensamble_panel.getSimulationModel()
Beispiel #3
0
def test_gui_iter_num(monkeypatch, tmpdir, qtbot, patch_enkf_main):
    # won't run simulations so we mock it and test whether "iter_num" is in arguments
    def _assert_iter_in_args(panel):
        assert "iter_num" in panel.getSimulationArguments()

    monkeypatch.setattr(
        ert_gui.simulation.simulation_panel.SimulationPanel,
        "runSimulation",
        _assert_iter_in_args,
    )
    # overrides realization count to 2
    monkeypatch.setattr(
        ert_gui.ertwidgets.models.activerealizationsmodel,
        "getRealizationCount",
        Mock(return_value=2),
    )

    monkeypatch.setattr(
        ert_gui.simulation.ensemble_experiment_panel,
        "getRealizationCount",
        Mock(return_value=2),
    )

    gui = _start_window(patch_enkf_main, "config.ert")
    qtbot.addWidget(gui)

    sim_mode = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_mode")
    qtbot.keyClick(sim_mode, Qt.Key_Down)

    sim_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_panel")

    ensemble_panel = gui.findChild(qtpy.QtWidgets.QWidget,
                                   name="Ensemble_experiment_panel")
    #simulate entering number 10 as iter_num
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Backspace)
    qtbot.keyClicks(ensemble_panel._iter_field, "10")
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Enter)

    start_simulation = gui.findChild(qtpy.QtWidgets.QWidget,
                                     name="start_simulation")
    qtbot.mouseClick(start_simulation, Qt.LeftButton)
    assert sim_panel.getSimulationArguments()["iter_num"] == 10