def __init__(self, parent, view=None, general_settings=None, categories_settings=None, plot_settings=None, fitting_settings=None): self.view = view if view else SettingsView(parent, self) self.general_settings = general_settings if general_settings else GeneralSettings( parent) self.categories_settings = categories_settings if categories_settings else CategoriesSettings( parent) self.plot_settings = plot_settings if plot_settings else PlotSettings( parent) self.fitting_settings = fitting_settings if fitting_settings else FittingSettings( parent) self.parent = parent self.view.sections.addItems(list(self.SETTINGS_TABS.values())) self.current = self.general_settings.view self.view.container.addWidget(self.general_settings.view) self.view.container.addWidget(self.categories_settings.view) self.view.container.addWidget(self.plot_settings.view) self.view.container.addWidget(self.fitting_settings.view) self.view.help_button.clicked.connect(self.action_open_help_window) self.ask_before_close = False
def test_load_current_setting_values(self, mock_ConfigService): # load current setting is called automatically in the constructor PlotSettings(None) mock_ConfigService.getString.assert_has_calls([ call(PlotSettings.NORMALIZATION), call(PlotSettings.SHOW_TITLE), call(PlotSettings.DEFAULT_AXIS_SCALE), call(PlotSettings.LINE_STYLE), call(PlotSettings.LINE_WIDTH), call(PlotSettings.ERROR_WIDTH), call(PlotSettings.CAPSIZE), call(PlotSettings.CAP_THICKNESS), call(PlotSettings.ERROR_EVERY), call(PlotSettings.IMAGE_SCALE) ])
def test_action_show_title_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_show_title_changed(Qt.Checked) mock_ConfigService.setString.assert_called_once_with(PlotProperties.SHOW_TITLE.value, "On") mock_ConfigService.setString.reset_mock() presenter.action_show_title_changed(Qt.Unchecked) mock_ConfigService.setString.assert_called_once_with(PlotProperties.SHOW_TITLE.value, "Off")
def test_action_line_width_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_line_width_changed(2) mock_ConfigService.setString.assert_called_once_with(PlotProperties.LINE_WIDTH.value, "2") mock_ConfigService.setString.reset_mock() presenter.action_line_width_changed(3.5) mock_ConfigService.setString.assert_called_once_with(PlotProperties.LINE_WIDTH.value, "3.5")
def test_action_legend_size_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_legend_size_changed(10) mock_ConfigService.setString.assert_called_once_with(PlotProperties.LEGEND_FONT_SIZE.value, '10') mock_ConfigService.setString.reset_mock() presenter.action_legend_size_changed(8) mock_ConfigService.setString.assert_called_once_with(PlotProperties.LEGEND_FONT_SIZE.value, '8')
def test_action_error_every_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_error_every_changed(2) mock_ConfigService.setString.assert_called_once_with(PlotProperties.ERROR_EVERY.value, "2") mock_ConfigService.setString.reset_mock() presenter.action_error_every_changed(5) mock_ConfigService.setString.assert_called_once_with(PlotProperties.ERROR_EVERY.value, "5")
def test_action_legend_every_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_legend_location_changed('best') mock_ConfigService.setString.assert_called_once_with(PlotProperties.LEGEND_LOCATION.value, 'best') mock_ConfigService.setString.reset_mock() presenter.action_legend_location_changed('upper left') mock_ConfigService.setString.assert_called_once_with(PlotProperties.LEGEND_LOCATION.value, 'upper left')
def test_action_cap_thickness_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_cap_thickness_changed(2) mock_ConfigService.setString.assert_called_once_with(PlotProperties.CAP_THICKNESS.value, "2") mock_ConfigService.setString.reset_mock() presenter.action_cap_thickness_changed(1.5) mock_ConfigService.setString.assert_called_once_with(PlotProperties.CAP_THICKNESS.value, "1.5")
def test_action_marker_size_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_marker_size_changed('8.0') mock_ConfigService.setString.assert_called_once_with(PlotProperties.MARKER_SIZE.value, "8.0") mock_ConfigService.setString.reset_mock() presenter.action_marker_size_changed('5.0') mock_ConfigService.setString.assert_called_once_with(PlotProperties.MARKER_SIZE.value, "5.0")
def test_action_marker_style_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_marker_style_changed('circle') mock_ConfigService.setString.assert_called_once_with(PlotProperties.MARKER_STYLE.value, "circle") mock_ConfigService.setString.reset_mock() presenter.action_marker_style_changed('octagon') mock_ConfigService.setString.assert_called_once_with(PlotProperties.MARKER_STYLE.value, "octagon")
def test_action_default_y_axes_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_default_y_axes_changed("Linear") mock_ConfigService.setString.assert_called_once_with(PlotProperties.Y_AXES_SCALE.value, "Linear") mock_ConfigService.setString.reset_mock() presenter.action_default_y_axes_changed("Log") mock_ConfigService.setString.assert_called_once_with(PlotProperties.Y_AXES_SCALE.value, "Log")
def test_action_normalization_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_normalization_changed(Qt.Checked) mock_ConfigService.setString.assert_called_once_with(PlotProperties.NORMALIZATION.value, "On") mock_ConfigService.setString.reset_mock() presenter.action_normalization_changed(Qt.Unchecked) mock_ConfigService.setString.assert_called_once_with(PlotProperties.NORMALIZATION.value, "Off")
def test_action_line_style_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_line_style_changed("dashed") mock_ConfigService.setString.assert_called_once_with(PlotProperties.LINE_STYLE.value, "dashed") mock_ConfigService.setString.reset_mock() presenter.action_line_style_changed("dotted") mock_ConfigService.setString.assert_called_once_with(PlotProperties.LINE_STYLE.value, "dotted")
def test_action_font_combo_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_font_combo_changed("Helvetica") mock_ConfigService.setString.assert_called_once_with(PlotProperties.PLOT_FONT.value, "Helvetica") mock_ConfigService.setString.reset_mock() presenter.action_font_combo_changed("Something that is not a font") mock_ConfigService.setString.assert_called_once_with(PlotProperties.PLOT_FONT.value, "Something that is not a font")
def test_action_default_axes_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_default_axes_changed("Log x/Log y") mock_ConfigService.setString.assert_called_once_with( PlotSettings.DEFAULT_AXIS_SCALE, "Log x/Log y") mock_ConfigService.setString.reset_mock() presenter.action_default_axes_changed("Lin x/Log y") mock_ConfigService.setString.assert_called_once_with( PlotSettings.DEFAULT_AXIS_SCALE, "Lin x/Log y")
def test_action_image_scale_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_image_scale_changed("Log") mock_ConfigService.setString.assert_called_once_with( PlotSettings.IMAGE_SCALE, "Log") mock_ConfigService.setString.reset_mock() presenter.action_image_scale_changed("Linear") mock_ConfigService.setString.assert_called_once_with( PlotSettings.IMAGE_SCALE, "Linear")
def test_action_capsize_changed(self, mock_ConfigService): presenter = PlotSettings(None) # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_capsize_changed(2) mock_ConfigService.setString.assert_called_once_with( PlotSettings.CAPSIZE, "2") mock_ConfigService.setString.reset_mock() presenter.action_capsize_changed(1.5) mock_ConfigService.setString.assert_called_once_with( PlotSettings.CAPSIZE, "1.5")
def test_load_current_setting_values(self, mock_ConfigService): # load current setting is called automatically in the constructor PlotSettings(None) mock_ConfigService.getString.assert_has_calls([ call(PlotProperties.NORMALIZATION.value), call(PlotProperties.SHOW_TITLE.value), call(PlotProperties.SHOW_LEGEND.value), call(PlotProperties.PLOT_FONT.value), call(PlotProperties.X_AXES_SCALE.value), call(PlotProperties.Y_AXES_SCALE.value), call(PlotProperties.AXES_LINE_WIDTH.value), call(PlotProperties.SHOW_TICKS_LEFT.value), call(PlotProperties.SHOW_TICKS_BOTTOM.value), call(PlotProperties.SHOW_TICKS_RIGHT.value), call(PlotProperties.SHOW_TICKS_TOP.value), call(PlotProperties.SHOW_LABELS_LEFT.value), call(PlotProperties.SHOW_LABELS_BOTTOM.value), call(PlotProperties.SHOW_LABELS_RIGHT.value), call(PlotProperties.SHOW_LABELS_TOP.value), call(PlotProperties.MAJOR_TICKS_LENGTH.value), call(PlotProperties.MAJOR_TICKS_WIDTH.value), call(PlotProperties.MAJOR_TICKS_DIRECTION.value), call(PlotProperties.MINOR_TICKS_LENGTH.value), call(PlotProperties.MINOR_TICKS_WIDTH.value), call(PlotProperties.MINOR_TICKS_DIRECTION.value), call(PlotProperties.ENABLE_GRID.value), call(PlotProperties.SHOW_MINOR_TICKS.value), call(PlotProperties.SHOW_MINOR_GRIDLINES.value), call(PlotProperties.LINE_STYLE.value), call(PlotProperties.DRAW_STYLE.value), call(PlotProperties.LINE_WIDTH.value), call(PlotProperties.MARKER_STYLE.value), call(PlotProperties.MARKER_SIZE.value), call(PlotProperties.ERROR_WIDTH.value), call(PlotProperties.CAPSIZE.value), call(PlotProperties.CAP_THICKNESS.value), call(PlotProperties.ERROR_EVERY.value), call(PlotProperties.LEGEND_LOCATION.value), call(PlotProperties.LEGEND_FONT_SIZE.value), call(PlotProperties.COLORMAP.value) ])
def __init__(self, parent, view=None, model=None, general_settings=None, categories_settings=None, plot_settings=None, fitting_settings=None): self.view = view if view else SettingsView(parent, self) self.model = model if model else SettingsModel() self.general_settings = general_settings if general_settings else GeneralSettings( parent, None, self) self.categories_settings = categories_settings if categories_settings else CategoriesSettings( parent) self.plot_settings = plot_settings if plot_settings else PlotSettings( parent) self.fitting_settings = fitting_settings if fitting_settings else FittingSettings( parent) self.parent = parent self.all_properties = [] for properties in [ CategoryProperties, FittingProperties, GeneralProperties, PlotProperties ]: self.all_properties += [prop.value for prop in properties] self.view.sections.addItems(list(self.SETTINGS_TABS.values())) self.current = self.general_settings.view self.view.container.addWidget(self.general_settings.view) self.view.container.addWidget(self.categories_settings.view) self.view.container.addWidget(self.plot_settings.view) self.view.container.addWidget(self.fitting_settings.view) self.view.save_file_button.clicked.connect( self.action_save_settings_to_file) self.view.load_file_button.clicked.connect( self.action_load_settings_from_file) self.view.help_button.clicked.connect(self.action_open_help_window) self.ask_before_close = False self.changes_that_need_restart = []
def test_action_default_colormap_changed(self, mock_ConfigService): presenter = PlotSettings(None) presenter.view.default_colormap_combo_box.setCurrentIndex(4) colormap = presenter.view.default_colormap_combo_box.currentText() # reset any effects from the constructor mock_ConfigService.setString.reset_mock() presenter.action_default_colormap_changed() mock_ConfigService.setString.assert_called_once_with(PlotProperties.COLORMAP.value, colormap) presenter.view.default_colormap_combo_box.setCurrentIndex(5) colormap = presenter.view.default_colormap_combo_box.currentText() presenter.view.reverse_colormap_check_box.setChecked(True) mock_ConfigService.setString.reset_mock() presenter.action_default_colormap_changed() mock_ConfigService.setString.assert_called_once_with(PlotProperties.COLORMAP.value, colormap+"_r")