Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_type_as_template(self):
typ = confuse.as_template(set)
self.assertIsInstance(typ, confuse.TypeTemplate)
self.assertEqual(typ.typ, set)
self.assertEqual(typ.default, confuse.REQUIRED)
def test_incorrect_type(self):
config = _root({'foo': dict()})
with self.assertRaises(confuse.ConfigTypeError):
config['foo'].get(confuse.TypeTemplate(set))
def test_missing_required_value(self):
config = _root({})
with self.assertRaises(confuse.NotFoundError):
config['foo'].get(confuse.TypeTemplate(set))
import yaml
logger = logging.getLogger(__name__)
class Config:
base_template = {
'twitter': {
'consumer_key': confuse.String(),
'consumer_secret': confuse.String(),
'access_token_key': confuse.String(),
'access_token_secret': confuse.String(),
'min_ratelimit_percent': confuse.Integer(),
'search': {
'queries': confuse.TypeTemplate(list),
'max_queue': confuse.Integer(),
'max_quote_depth': confuse.Integer(),
'min_quote_similarity': confuse.Number(),
'skip_retweeted': confuse.TypeTemplate(bool),
# Is updated on runtime
'filter': {},
# Is updated on runtime
'sort': {},
},
# Is updated on runtime
'actions': {},
'scheduler': {
'search_interval': confuse.Integer(),
'retweet_interval': confuse.Integer(),
'retweet_random_margin': confuse.Integer(),
'blocked_users_update_interval': confuse.Integer(),
def get_config_template():
template = {
'enabled': confuse.TypeTemplate(bool),
'keywords': confuse.StrSeq(),
'max_following': confuse.Integer(),
'multiple': confuse.TypeTemplate(bool)
}
return template
def get_config_template():
template = {
'enabled': confuse.TypeTemplate(bool),
'keywords': confuse.StrSeq()
}
return template
def get_config_template():
template = {
'enabled': confuse.TypeTemplate(bool),
'host': confuse.String(),
'port': confuse.Integer(),
'tls': confuse.TypeTemplate(bool),
'username': confuse.String(),
'password': confuse.String(),
'recipient': confuse.String()
}
return template
def get_config_template():
template = {
'enabled': confuse.TypeTemplate(bool),
}
return template