Skip to content

Commit

Permalink
Improve the epochs_create a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
teekuningas committed Feb 23, 2024
1 parent 0f533ae commit 26f0d55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
12 changes: 4 additions & 8 deletions meggie/actions/epochs_create/tests/test_epochs_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@

class TestEpochsCreate(BaseTestAction):
def test_create_epochs_dialog(self):
def patched_exc_messagebox(parent, exc, exec_=False):
raise exc

self.monkeypatch.setattr(
"meggie.actions.epochs_create.dialogs.createEpochsFromEventsDialogMain.exc_messagebox",
patched_exc_messagebox,
)

self.run_action(
tab_id="epochs", action_name="epochs_create", handler=CreateEpochs
tab_id="epochs",
action_name="epochs_create",
handler=CreateEpochs,
dialog_path="meggie.actions.epochs_create.dialogs.createEpochsFromEventsDialogMain",
)
dialog = self.find_dialog(CreateEpochsFromEventsDialog)

Expand Down
19 changes: 18 additions & 1 deletion meggie/utilities/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def load_action_spec(action_name):
return action_spec


def patched_messagebox(parent, message):
raise Exception(message)


def patched_exc_messagebox(parent, exc, exec_=False):
raise exc


class BaseTestAction:
@pytest.fixture(autouse=True)
def setup_common(self, qtbot, monkeypatch):
Expand All @@ -49,7 +57,16 @@ def setup_experiment(self):
)
self.experiment.activate_subject("sample_01-raw")

def run_action(self, tab_id, action_name, handler):
def run_action(self, tab_id, action_name, handler, dialog_path):

self.monkeypatch.setattr(
".".join([dialog_path, "exc_messagebox"]),
patched_exc_messagebox,
)
self.monkeypatch.setattr(
".".join([dialog_path, "messagebox"]),
patched_messagebox,
)
data = {"tab_id": tab_id}
action_spec = load_action_spec(action_name)
self.action_instance = handler(
Expand Down

0 comments on commit 26f0d55

Please sign in to comment.