Esempio n. 1
0
 def test_get_environment_returns_part_of_dict(self):
     config = Config('')
     test = {
         'KEY': False,
         'environments': {
             'debug': {
                 'DEBUG': True
             },
             'testing': {
                 'TESTING': True
             }
         }
     }
     assert config._get_environment('debug', test) == {
         'DEBUG': True,
         'KEY': False
     }
Esempio n. 2
0
 def test_get_environment_returns_part_of_dict(self):
     config = Config('')
     test = {
         'KEY': False,
         'environments': {
             'debug': {
                 'DEBUG': True
             },
             'testing': {
                 'TESTING': True
             }
         }
     }
     assert config._get_environment('debug', test) == {
         'DEBUG': True,
         'KEY': False
     }
Esempio n. 3
0
    def environment_test(self, filename):
        config = Config('')
        config.from_toml(filename, environment='dev')

        assert config['TEST_KEY'] == 'foo'
        assert config['SECRET_KEY'] == 'devkey'
        assert config['DEBUG'] == True
        assert 'TESTING' not in config
        assert 'ignored' not in config

        config = Config('')
        config.from_toml(filename, environment='testing')
        assert config['TEST_KEY'] == 'foo'
        assert config['SECRET_KEY'] == 'devkey'
        assert config['TESTING'] == True
        assert 'DEBUG' not in config
        assert 'ignored' not in config
Esempio n. 4
0
    def environment_test(self, filename):
        config = Config('')
        config.from_toml(filename, environment='dev')

        assert config['TEST_KEY'] == 'foo'
        assert config['SECRET_KEY'] == 'devkey'
        assert config['DEBUG'] == True
        assert 'TESTING' not in config
        assert 'ignored' not in config

        config = Config('')
        config.from_toml(filename, environment='testing')
        assert config['TEST_KEY'] == 'foo'
        assert config['SECRET_KEY'] == 'devkey'
        assert config['TESTING'] == True
        assert 'DEBUG' not in config
        assert 'ignored' not in config
Esempio n. 5
0
    def make_config(self, instance_relative=False):
        root_path = self.root_path

        if instance_relative:
            root_path = self.instance_path
        return Config(root_path, self.default_config)
Esempio n. 6
0
 def test_toml_advanced(self):
     config = Config('')
     config.from_toml(self.example_prefix('advanced.toml'))
     self.advanced_test(config)
Esempio n. 7
0
 def test_toml_basic(self):
     config = Config('')
     config.from_toml(self.example_prefix('basic.toml'))
     self.basic_test(config)
Esempio n. 8
0
 def test_toml_format_error(self):
     with pytest.raises(toml.TomlError):
         example = self.example_prefix('format_err.toml')
         config = Config('')
         config.from_toml(example)
Esempio n. 9
0
 def test_toml_advanced(self):
     config = Config('')
     config.from_toml(self.example_prefix('advanced.toml'))
     self.advanced_test(config)
Esempio n. 10
0
 def test_toml_basic(self):
     config = Config('')
     config.from_toml(self.example_prefix('basic.toml'))
     self.basic_test(config)
Esempio n. 11
0
 def test_toml_format_error(self):
     with pytest.raises(toml.TomlError):
         example = self.example_prefix('format_err.toml')
         config = Config('')
         config.from_toml(example)