def __init__(self): self._log = logging.getLogger('pushbullet') token = Config('pushbullet').get('token') if token is None: msg = 'No pushbullet access token found. Check Config docs.' self._log.error(msg) raise AttributeError(msg) self._token = token
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'))