Exemple #1
0
    def test_load_configuration(self):
        Configuration().core_clear()
        rsp = RsParameters()
        self.assertEquals("test_rs_paras", rsp.configuration_name())

        rsp.max_items_in_list = 5566
        rsp.save_configuration_as("realy_not_a_name_for_config")
        self.assertEquals("realy_not_a_name_for_config",
                          rsp.configuration_name())

        rsp = RsParameters(config_name="realy_not_a_name_for_config")
        self.assertEquals(5566, rsp.max_items_in_list)

        self.assertTrue("realy_not_a_name_for_config" in
                        Configurations.list_configurations())

        Configurations.remove_configuration("realy_not_a_name_for_config")

        with self.assertRaises(Exception) as context:
            RsParameters(config_name="realy_not_a_name_for_config")
        self.assertIsInstance(context.exception, ValueError)

        Configuration().reset()
        rsp = RsParameters()
        self.assertEquals("realy_not_a_name_for_config",
                          rsp.configuration_name())
Exemple #2
0
    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())
Exemple #3
0
    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")
Exemple #4
0
 def on_btn_delete_clicked(self):
     items = [x.data() for x in self.selection_model.selectedIndexes()]
     msg_box = QMessageBox()
     msg_box.setText(_("Delete configurations"))
     if len(items) == 1:
         i_text = _("Delete configuration '%s'" % items[0])
     else:
         i_text = _("Delete %d configurations" % len(items))
     i_text += "\n\n"
     i_text += _("Ok to proceed?")
     msg_box.setInformativeText(i_text)
     msg_box.setIcon(QMessageBox.Question)
     msg_box.setStandardButtons(QMessageBox.No | QMessageBox.Yes)
     msg_box.setDefaultButton(QMessageBox.Yes)
     exe = msg_box.exec()
     if exe == QMessageBox.Yes:
         for item in self.selection_model.selectedIndexes():
             Configurations.remove_configuration(item.data())
         self.populate_model()
         self.on_selection_changed()
Exemple #5
0
    def do_remove_configuration(self, name):
        """
remove_configuration [name]::

    Remove a saved configuration

        """
        if name:
            if self.__confirm__("Remove configuration '%s'?" % name):
                if Configurations.remove_configuration(name):
                    print("Removed configuration %s" % name)
                else:
                    print("No configuration with the name %s" % name)
        else:
            print("Remove a configuration. Specify a name:")
            self.do_list_configurations(name)