Skip to content

Commit

Permalink
Fix hanging test_rft_csv_export_plugin_exports_rft_data
Browse files Browse the repository at this point in the history
Handle the finished dialog that pops up on completion of the plugin.
  • Loading branch information
DanSava committed Sep 20, 2023
1 parent 080c8df commit c43ed44
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/unit_tests/gui/test_rft_export_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from unittest.mock import Mock

import pytest
from qtpy.QtCore import QTimer
from qtpy.QtCore import Qt, QTimer
from qtpy.QtWidgets import QMessageBox

from ert.config import ErtConfig
from ert.enkf_main import EnKFMain
Expand Down Expand Up @@ -64,7 +65,6 @@ def gen_data_in_runpath(tmp_path):
)


@pytest.mark.skip(reason="This test is causing Coverage GUI tests to hang")
@pytest.mark.usefixtures("use_tmpdir")
def test_rft_csv_export_plugin_exports_rft_data(
qtbot, ert_rft_setup, well_file, gen_data_in_runpath
Expand Down Expand Up @@ -106,11 +106,22 @@ def handle_rft_plugin_dialog():
list_field._list_edit_line.setText("default")
dialog.accept()

QTimer.singleShot(1000, handle_rft_plugin_dialog)
def handle_finished_box():
"""
Click on the plugin finished dialog once it pops up
"""
qtbot.waitUntil(lambda: isinstance(gui.findChild(QMessageBox), QMessageBox))
finished_message = gui.findChild(QMessageBox)
assert isinstance(finished_message, QMessageBox)
assert "completed" in finished_message.text()
qtbot.mouseClick(finished_message.button(QMessageBox.Ok), Qt.LeftButton)

plugin_actions = gui.tools["Plugins"].getAction().menu().actions()
rft_plugin = [
a for a in plugin_actions if a.iconText() == "GEN_DATA RFT CSV Export"
][0]
QTimer.singleShot(500, handle_rft_plugin_dialog)
QTimer.singleShot(2000, handle_finished_box)
rft_plugin.trigger()
qtbot.waitUntil(output_file.exists, timeout=20000)
qtbot.waitUntil(
Expand Down

0 comments on commit c43ed44

Please sign in to comment.