def test_default_value_for_nonexistent_key(self): cfg = Config(TestConfig.section) default = 'default' value = cfg.get(TestConfig.nonexistent, default) self.assertIs(default, value)
def test_no_default_value_for_existent_key(self): cfg = Config(TestConfig.section) value = cfg.get(TestConfig.key, TestConfig.nonexistent) self.assertEqual(TestConfig.value, value)
def test_nonexistent_key(self): cfg = Config(TestConfig.section) self.assertIsNone(cfg.get(TestConfig.nonexistent))
def test_nonexistent_section(self): cfg = Config(TestConfig.nonexistent) self.assertIsNone(cfg.get('test'))
def test_default_ini_if_user_file_does_not_exist(self): with patch.object(Config, 'user_ini', TestConfig.nonexistent): cfg = Config(TestConfig.section) self.assertIsNotNone(cfg.get(TestConfig.key))
def __init__(self): cfg = Config('cloudstack') super().__init__(cfg.get('url'), cfg.get('key'), cfg.get('secret')) self._logger = ExpyLogger.getLogger('cloudstack.api')