def test_environment_overlay(self): os.environ['TEST_VAR1'] = 'test-value' config = core.Config() self.assertConfigExpectations(config, { 'TEST_VAR1': 'test-value', 'TEST_VAR2': None, })
def test_aliases(self): config = core.Config() config.register_alias('port', 'service_port') config.set_default('service_port', 1234) self.assertConfigExpectations(config, { 'port': 1234, 'service_port': 1234, 'nonexistent': None, })
def test_dotted_resolution(self): os.environ['REDIS_PORT'] = '1234' config = core.Config() config.set('redis', {'db': 10}) config.set_default('redis.host', 'example.com') self.assertConfigExpectations( config, { 'redis.db': 10, 'redis.port': '1234', 'redis.host': 'example.com', 'nonexistent': None, })
def test_defaults_and_overrides(self): os.environ['A'] = '4' config = core.Config() config.set_default('A', 1) config.set_default('B', 2) config.set_default('C', 3) self.assertConfigExpectations(config, { 'A': '4', 'B': 2, 'C': 3, 'D': None, })
def test_environment_with_explicit_override(self): os.environ['TEST_VAR1'] = 'test-value' config = core.Config() self.assertConfigExpectations(config, { 'TEST_VAR1': 'test-value', 'TEST_VAR2': None, }) config.set('TEST_VAR1', 'another-value') config.set('TEST_VAR2', 'a-second-value') self.assertConfigExpectations(config, { 'TEST_VAR1': 'another-value', 'TEST_VAR2': 'a-second-value', })