def create_toolboxui_with_project(project_dir): """Returns ToolboxUI with a project instance where QSettings among others has been mocked.""" with mock.patch("spinetoolbox.ui_main.ToolboxUI.save_project"), mock.patch( "spinetoolbox.ui_main.ToolboxUI.update_recent_projects" ), mock.patch( "spinetoolbox.ui_main.QSettings.value" ) as mock_qsettings_value, mock.patch( "spinetoolbox.widgets.open_project_widget.OpenProjectDialog.update_recents" ), mock.patch("spinetoolbox.plugin_manager.PluginManager.load_plugins"): mock_qsettings_value.side_effect = qsettings_value_side_effect toolbox = ToolboxUI() toolbox.create_project("UnitTest Project", "Project for unit tests.", project_dir) return toolbox
def create_toolboxui(): """Returns ToolboxUI, where QSettings among others has been mocked.""" with mock.patch( "spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value: # Replace Julia REPL Widget with a QWidget so that the DeprecationWarning from qtconsole is not printed mock_qsettings_value.side_effect = qsettings_value_side_effect toolbox = ToolboxUI() return toolbox
def create_toolboxui(): """Returns ToolboxUI, where QSettings among others has been mocked.""" with mock.patch("spinetoolbox.plugin_manager.PluginManager.load_plugins" ), mock.patch("spinetoolbox.ui_main.QSettings.value" ) as mock_qsettings_value: mock_qsettings_value.side_effect = qsettings_value_side_effect toolbox = ToolboxUI() return toolbox
def create_toolboxui_with_project(): """Returns ToolboxUI with a project instance where QSettings among others has been mocked.""" with mock.patch("spinetoolbox.ui_main.JuliaREPLWidget") as mock_julia_repl, \ mock.patch("spinetoolbox.ui_main.PythonReplWidget") as mock_python_repl, \ mock.patch("spinetoolbox.project.create_dir") as mock_create_dir, \ mock.patch("spinetoolbox.ui_main.ToolboxUI.save_project") as mock_save_project, \ mock.patch("spinetoolbox.ui_main.ToolboxUI.update_recent_projects") as mock_update_recents, \ mock.patch("spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value, \ mock.patch("spinetoolbox.widgets.open_project_widget.OpenProjectDialog.update_recents") as mock_upd_recents: # Replace Julia REPL Widget with a QWidget so that the DeprecationWarning from qtconsole is not printed mock_julia_repl.return_value = QWidget() mock_python_repl.return_value = MockQWidget() mock_qsettings_value.side_effect = qsettings_value_side_effect toolbox = ToolboxUI() project_dir = os.path.abspath( os.path.join(os.curdir, "tests", "test_resources", "This dir should not exist after tests")) toolbox.create_project("UnitTest Project", "Project for unit tests.", project_dir) return toolbox
def create_toolboxui_with_project(): """Returns ToolboxUI with a project instance where QSettings among others has been mocked.""" with mock.patch( "spinetoolbox.project.create_dir" ) as mock_create_dir, mock.patch( "spinetoolbox.ui_main.ToolboxUI.save_project" ) as mock_save_project, mock.patch( "spinetoolbox.ui_main.ToolboxUI.update_recent_projects" ) as mock_update_recents, mock.patch( "spinetoolbox.ui_main.QSettings.value" ) as mock_qsettings_value, mock.patch( "spinetoolbox.widgets.open_project_widget.OpenProjectDialog.update_recents" ) as mock_upd_recents: mock_qsettings_value.side_effect = qsettings_value_side_effect toolbox = ToolboxUI() project_dir = os.path.abspath( os.path.join(os.curdir, "tests", "test_resources", "This dir should not exist after tests")) toolbox.create_project("UnitTest Project", "Project for unit tests.", project_dir) return toolbox