Ejemplo n.º 1
0
    def test_override_config2(self):
        config = Config({
            'resources.i18n': {
                'timezone': 'America/Sao_Paulo',
            },
        })

        assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
        assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
Ejemplo n.º 2
0
    def test_default_config(self):
        config = Config()

        from resources.template import default_config as template_config
        from resources.i18n import default_config as i18n_config

        assert config.load_and_get('resources.template', 'templates_dir') == template_config['templates_dir']
        assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']
        assert config.load_and_get('resources.i18n', 'timezone') == i18n_config['timezone']
Ejemplo n.º 3
0
    def test_default_config_with_non_existing_key(self):
        config = Config()

        from resources.i18n import default_config as i18n_config

        # In the first time the module config will be loaded normally.
        assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']

        # In the second time it won't be loaded, but won't find the value and then use the default.
        assert config.load_and_get('resources.i18n', 'i_dont_exist', 'foo') == 'foo'
Ejemplo n.º 4
0
    def test_override_config(self):
        config = Config({
            'resources.template': {
                'templates_dir': 'apps/templates'
            },
            'resources.i18n': {
                'locale': 'pt_BR',
                'timezone': 'America/Sao_Paulo',
            },
        })

        assert config.load_and_get('resources.template', 'templates_dir') == 'apps/templates'
        assert config.load_and_get('resources.i18n', 'locale') == 'pt_BR'
        assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
Ejemplo n.º 5
0
 def test_missing_default_config(self):
     config = Config()
     assert config.load_and_get('webapp2', 'foo') == 'baz'
Ejemplo n.º 6
0
 def test_missing_key(self):
     config = Config()
     config.load_and_get('resources.i18n', 'i_dont_exist')
Ejemplo n.º 7
0
 def test_missing_module2(self):
     config = Config()
     assert config.load_and_get('i_dont_exist') == 'baz'
Ejemplo n.º 8
0
 def test_required_config(self):
     config = Config()
     config.load_and_get('resources.i18n', 'required')
Ejemplo n.º 9
0
 def test_get_with_default_and_module_load(self):
     config = Config()
     assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
     assert config.load_and_get('resources.i18n', 'locale', 'foo') == 'en_US'
Ejemplo n.º 10
0
    def test_get_with_default_and_none(self):
        config = Config({'foo': {
            'bar': None,
        }})

        assert config.load_and_get('foo', 'bar', 'ooops') is None
Ejemplo n.º 11
0
    def test_get_with_default(self):
        config = Config()

        assert config.load_and_get('resources.i18n', 'bar', 'baz') == 'baz'
Ejemplo n.º 12
0
    def test_get(self):
        config = Config({'foo': {
            'bar': 'baz',
        }})

        assert config.load_and_get('foo', 'bar') == 'baz'