Beispiel #1
0
    def test_get_values(self):
        _dyna_controller.reset()
        register_dyna_settings(ChildOK_Match())
        register_dyna_settings(ChildOK_NoMatch())

        val = dyna_value('A', production_value='x')
        self.assertEqual(val, 'a')
        val = dyna_value('B', production_value='x')
        self.assertEqual(val, 'b')

        val = dyna_value('UNDEFINED', production_value='prod')
        self.assertEqual(val, 'prod')
    def test_get_values(self):
        _dyna_controller.reset()
        register_dyna_settings(ChildOK_Match())
        register_dyna_settings(ChildOK_NoMatch())

        val = dyna_value('A', production_value='x')
        self.assertEqual(val, 'a')
        val = dyna_value('B', production_value='x')
        self.assertEqual(val, 'b')

        val = dyna_value('UNDEFINED', production_value='prod')
        self.assertEqual(val, 'prod')
    def test_environ_var_trump_fail(self):
        """
        Verifies that if Trump is true, environment doesn't have the variable, production_value doesn't
        define it, and the class does not either, then exception is raised.
        :return:
        """
        _dyna_controller.reset()
        register_dyna_settings(EnvSettingTrue())

        with self.assertRaises(NoMatchingSettingsClass):
            bad = dyna_value('VOODOOUDO', production_value=None)
            print bad
    def test_environ_var_trump_no_env_var(self):
        """
        Verify that if trump is True but the environment var is not defined we'll still pick
        up the value if the class instance has defined it
        :return:
        """
        _dyna_controller.reset()

        register_dyna_settings(EnvSettingTrue())

        path = dyna_value('AINT_THAR', production_value=None)
        self.assertTrue(path)
Beispiel #5
0
    def test_environ_var_trump_fail(self):
        """
        Verifies that if Trump is true, environment doesn't have the variable, production_value doesn't
        define it, and the class does not either, then exception is raised.
        :return:
        """
        _dyna_controller.reset()
        register_dyna_settings(EnvSettingTrue())

        with self.assertRaises(NoMatchingSettingsClass):
            bad = dyna_value('VOODOOUDO', production_value=None)
            print bad
Beispiel #6
0
    def test_environ_var_trump_no_env_var(self):
        """
        Verify that if trump is True but the environment var is not defined we'll still pick
        up the value if the class instance has defined it
        :return:
        """
        _dyna_controller.reset()

        register_dyna_settings(EnvSettingTrue())

        path = dyna_value('AINT_THAR', production_value=None)
        self.assertTrue(path)
    def test_environ_var_trump_global(self):
        """
        Verify that with the global trump set True we'll get from the environment
        :return:
        """
        DynaSettingsController.set_environ_vars_trump(flag=True)

        self.assertTrue(_dyna_controller.environ_vars_trump)
        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)

        path_from_settings = dyna_value('PATH', production_value=None)
        self.assertTrue(path_from_settings)
        self.assertEqual(path_from_settings, path)
Beispiel #8
0
    def test_environ_var_trump_global(self):
        """
        Verify that with the global trump set True we'll get from the environment
        :return:
        """
        DynaSettingsController.set_environ_vars_trump(flag=True)

        self.assertTrue(_dyna_controller.environ_vars_trump)
        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)

        path_from_settings = dyna_value('PATH', production_value=None)
        self.assertTrue(path_from_settings)
        self.assertEqual(path_from_settings, path)
    def test_environ_var_trump_off(self):
        """
        Verify that with the environment var trump off we obtain the value from
        our dyna settings and not the environment variable.
        :return:
        """
        DynaSettingsController.set_environ_vars_trump(flag=False)

        self.assertFalse(_dyna_controller.environ_vars_trump)
        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)

        path_from_settings = dyna_value('PATH', production_value='Internal path')
        self.assertTrue(path_from_settings)
        self.assertNotEqual(path_from_settings, path)
Beispiel #10
0
    def test_environ_var_trump_off(self):
        """
        Verify that with the environment var trump off we obtain the value from
        our dyna settings and not the environment variable.
        :return:
        """
        DynaSettingsController.set_environ_vars_trump(flag=False)

        self.assertFalse(_dyna_controller.environ_vars_trump)
        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)

        path_from_settings = dyna_value('PATH',
                                        production_value='Internal path')
        self.assertTrue(path_from_settings)
        self.assertNotEqual(path_from_settings, path)
    def test_environ_var_trump_instance(self):
        """
        Verify that, with a DynaSettings instance registered that sets trump True it behaves
        properly by obtaining the value from the environment variable. Should ignore both the
        production_value and the settings class definition.
        :return:
        """
        _dyna_controller.reset()
        self.assertFalse(_dyna_controller.environ_vars_trump)

        register_dyna_settings(EnvSettingTrue())

        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)
        path_from_settings = dyna_value('PATH', production_value='Internal path')
        self.assertTrue(path_from_settings)
        self.assertEqual(path_from_settings, path)
Beispiel #12
0
    def test_environ_var_trump_instance(self):
        """
        Verify that, with a DynaSettings instance registered that sets trump True it behaves
        properly by obtaining the value from the environment variable. Should ignore both the
        production_value and the settings class definition.
        :return:
        """
        _dyna_controller.reset()
        self.assertFalse(_dyna_controller.environ_vars_trump)

        register_dyna_settings(EnvSettingTrue())

        import os

        path = os.environ.get('PATH')
        self.assertTrue(path)
        path_from_settings = dyna_value('PATH',
                                        production_value='Internal path')
        self.assertTrue(path_from_settings)
        self.assertEqual(path_from_settings, path)
    def test_get_values_with_no_settings_class(self):
        _dyna_controller.reset()

        with self.assertRaises(NoMatchingSettingsClass):
            val = dyna_value('BAD')
Beispiel #14
0
    def test_get_values_with_no_settings_class(self):
        _dyna_controller.reset()

        with self.assertRaises(NoMatchingSettingsClass):
            val = dyna_value('BAD')