def test_load_configuration(self): Configurations.remove_configuration("test_load_1") Configurations.remove_configuration("test_load_2") Configuration.reset() cfg1 = Configuration() cfg2 = Configuration() self.assertIs(cfg1, cfg2) self.assertEquals(Configurations.current_configuration_name(), cfg1.name()) self.assertEquals(Configurations.current_configuration_name(), cfg2.name()) Configurations.save_configuration_as("test_load_1") self.assertEquals("test_load_1", cfg1.name()) Configuration.reset() cfg3 = Configuration() self.assertIsNot(cfg1, cfg3) self.assertEquals(Configurations.current_configuration_name(), cfg3.name()) Configurations.save_configuration_as("test_load_2") self.assertEquals("test_load_1", cfg1.name()) self.assertEquals("test_load_1", cfg2.name()) self.assertEquals("test_load_2", cfg3.name()) Configurations.load_configuration("test_load_1") cfg4 = Configuration() self.assertEquals("test_load_1", cfg1.name()) self.assertEquals("test_load_1", cfg2.name()) self.assertEquals("test_load_2", cfg3.name()) self.assertEquals("test_load_1", cfg4.name())
def test_current_configuration_name(self): # No name change current_name = Configurations.current_configuration_name() Configuration.reset() self.assertEquals(current_name, Configurations.current_configuration_name()) cfg1 = Configuration() Configurations.save_configuration_as("test_current") self.assertEquals("test_current", Configurations.current_configuration_name()) Configurations.remove_configuration("test_current")
def configuration_name(): """ ``function`` :samp:`Current configuration name` :return: current configuration name """ return Configurations.current_configuration_name()
def on_menu_open_config_about_to_show(self): self.menu_open_config.clear() for child in self.config_action_group.children(): self.config_action_group.removeAction(child) current_name = Configurations.current_configuration_name() for name in Configurations.list_configurations(): action = QAction(name, self) action.setCheckable(True) action.setData(name) self.config_action_group.addAction(action) self.menu_open_config.addAction(action) if name == current_name: action.setChecked(True)