Ejemplo n.º 1
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())
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
    def save_configuration_as(self, name: str):
        """
        ``function`` :samp:`Save current configuration under {name}`

        Save the current configuration under the given `name`. If a configuration under the given `name` already
        exists it will be overwritten without warning.

        :param str name: the name under which the configuration will be saved

        See also: :func:`~rspub.core.config.Configurations.load_configuration`
        """
        self.save_configuration(False)
        Configurations.save_configuration_as(name)