Example #1
0
    def test_basic(self):
        appier.conf_s("NAME", "name")
        result = appier.conf("NAME")

        self.assertEqual(result, "name")

        result = appier.conf("NAME", cast=str)

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        result = appier.conf("NAME", cast="str")

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        appier.conf_s("AGE", "10")
        result = appier.conf("AGE", cast=int)

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = appier.conf("AGE", cast="int")

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = appier.conf("AGE", cast=str)

        self.assertEqual(result, "10")
        self.assertEqual(type(result), str)

        result = appier.conf("HEIGHT")

        self.assertEqual(result, None)
Example #2
0
    def test_basic(self):
        appier.conf_s("NAME", "name")
        result = appier.conf("NAME")

        self.assertEqual(result, "name")

        result = appier.conf("NAME", cast = str)

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        result = appier.conf("NAME", cast = "str")

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        appier.conf_s("AGE", "10")
        result = appier.conf("AGE", cast = int)

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = appier.conf("AGE", cast = "int")

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = appier.conf("AGE", cast = str)

        self.assertEqual(result, "10")
        self.assertEqual(type(result), str)

        result = appier.conf("HEIGHT")

        self.assertEqual(result, None)
Example #3
0
    def test_none(self):
        appier.conf_s("AGE", None)
        result = appier.conf("AGE", cast = int)

        self.assertEqual(result, None)

        result = appier.conf("HEIGHT", cast = int)

        self.assertEqual(result, None)
Example #4
0
    def test_none(self):
        appier.conf_s("AGE", None)
        result = appier.conf("AGE", cast = int)

        self.assertEqual(result, None)

        result = appier.conf("HEIGHT", cast = int)

        self.assertEqual(result, None)
Example #5
0
    def _flush(cls):
        # retrieves the dictionary of configurations currently
        # enabled in the data source
        config_d = cls.config_d()

        # iterates over the complete set of configuration
        # key in the previous configuration, to try to determine
        # the ones that have been removed
        for key in cls._CONFIG:
            if key in config_d: continue
            appier.conf_r(key)

        # iterates over the complete set of key value pairs
        # in the configuration dictionary to set these configuration
        for key, value in appier.legacy.iteritems(config_d):
            appier.conf_s(key, value)

        # updates the current configuration dictionary with
        # the one that has just been retrieved
        cls._CONFIG = config_d
Example #6
0
    def _flush(cls):
        # retrieves the dictionary of configurations currently
        # enabled in the data source
        config_d = cls.config_d()

        # iterates over the complete set of configuration
        # key in the previous configuration, to try to determine
        # the ones that have been removed
        for key in cls._CONFIG:
            if key in config_d: continue
            appier.conf_r(key)

        # iterates over the complete set of key value pairs
        # in the configuration dictionary to set these configuration
        for key, value in appier.legacy.iteritems(config_d):
            appier.conf_s(key, value)

        # updates the current configuration dictionary with
        # the one that has just been retrieved
        cls._CONFIG = config_d