def test_saving_as_template(windows, tmpdir, task_workbench, task, monkeypatch): """Test saving a task as a template. """ from ecpy.tasks.utils import saving monkeypatch.setattr(saving.TemplateViewer, 'exec_', saving.TemplateViewer.show) plugin = task_workbench.get_plugin('ecpy.tasks') plugin.templates = {'test': ''} def answer_dialog(dialog): model = dialog._model model.folder = str(tmpdir) model.filename = 'test' model.doc = 'This is a test' dialog.show_result = True assert model.accept_template_info(dialog) core = task_workbench.get_plugin('enaml.workbench.core') with handle_dialog('accept', answer_dialog): core.invoke_command(CMD, dict(task=task, mode='template')) get_window(Dialog).accept() process_app_events() path = str(tmpdir.join('test.task.ini')) assert os.path.isfile(path) config = ConfigObj(path) assert config.initial_comment == ['# This is a test']
def test_root_view(windows, task_workbench, dialog_sleep): """Test the behavior of the root task view. """ task = RootTask() view = RootTaskView(task=task, core=task_workbench.get_plugin('enaml.workbench.core')) editor = view.children[-1] win = show_widget(view) sleep(dialog_sleep) assert editor.task is task assert editor.root is view TASK_NAME = 'Foo' def answer_dialog(dial): selector = dial.selector selector.selected_task = 'ecpy.ComplexTask' dial.config.task_name = TASK_NAME process_app_events() with handle_dialog('accept', answer_dialog, cls=BuilderView): editor._empty_button.clicked = True process_app_events() assert task.children assert type(task.children[0]) is ComplexTask assert len(editor._children_buttons) == 1 sleep(dialog_sleep) TASK_NAME = 'Bar' with handle_dialog('accept', answer_dialog, cls=BuilderView): editor.operations['add'](0, 'after') process_app_events() sleep(dialog_sleep) task.children[0].add_child_task(0, ComplexTask(name='Test')) get_window().maximize() process_app_events() sleep(dialog_sleep) editor.operations['move'](0, 1) process_app_events() sleep(dialog_sleep) task.remove_child_task(1) process_app_events() sleep(dialog_sleep) assert len(view._cache) == 2 editor.operations['remove'](0) process_app_events() sleep(dialog_sleep) assert len(view._cache) == 1 win.close()
def test_root_view(windows, task_workbench, dialog_sleep): """Test the behavior of the root task view. """ task = RootTask() view = RootTaskView(task=task, core=task_workbench.get_plugin('enaml.workbench.core')) editor = view.children[0] win = show_widget(view) sleep(dialog_sleep) assert editor.task is task assert editor.root is view TASK_NAME = 'Foo' def answer_dialog(dial): selector = dial.selector selector.selected_task = 'ecpy.ComplexTask' dial.config.task_name = TASK_NAME process_app_events() with handle_dialog('accept', answer_dialog, cls=BuilderView): editor._empty_button.clicked = True process_app_events() assert task.children assert type(task.children[0]) is ComplexTask assert len(editor._children_buttons) == 1 sleep(dialog_sleep) TASK_NAME = 'Bar' with handle_dialog('accept', answer_dialog, cls=BuilderView): editor.operations['add'](0, 'after') process_app_events() sleep(dialog_sleep) task.children[0].add_child_task(0, ComplexTask(name='Test')) get_window().maximize() process_app_events() sleep(dialog_sleep) editor.operations['move'](0, 1) task.children[1].remove_child_task(0) assert len(view._cache) == 3 editor.operations['remove'](0) assert len(view._cache) == 2 win.close()
def test_gathering_mode(workbench, windows): """Test gathering multiple errors. """ core = workbench.get_plugin('enaml.workbench.core') core.invoke_command('ecpy.app.errors.enter_error_gathering') core.invoke_command('ecpy.app.errors.signal', {'kind': 'stupid', 'msg': None}) assert get_window() is None with handle_dialog(): core.invoke_command('ecpy.app.errors.exit_error_gathering')
def test_gathering_mode(err_workbench, windows): """Test gathering multiple errors. """ core = err_workbench.get_plugin('enaml.workbench.core') core.invoke_command('ecpy.app.errors.enter_error_gathering') core.invoke_command('ecpy.app.errors.signal', { 'kind': 'stupid', 'msg': None }) assert get_window() is None with handle_dialog(): core.invoke_command('ecpy.app.errors.exit_error_gathering')