How to use the confuse.Integer function in confuse

To help you get started, we’ve selected a few confuse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beetbox / confuse / test / test_valid.py View on Github external
def test_missing_required_value_raises_error_on_validate(self):
        config = _root({})
        with self.assertRaises(confuse.NotFoundError):
            config.get({'foo': confuse.Integer()})
github beetbox / confuse / test / test_valid.py View on Github external
def test_validate_first_good_choice_in_list(self):
        config = _root({'foo': 3.14})
        valid = config['foo'].get(confuse.OneOf([
            confuse.Integer(),
            confuse.Number(),
        ]))
        self.assertEqual(valid, 3)
github beetbox / confuse / test / test_valid.py View on Github external
def test_validate_no_choice_in_list(self):
        config = _root({'foo': None})
        with self.assertRaises(confuse.ConfigValueError):
            config['foo'].get(confuse.OneOf([
                confuse.String(),
                confuse.Integer(),
            ]))
github beetbox / confuse / test / test_valid.py View on Github external
def test_validate_good_choice_in_list(self):
        config = _root({'foo': 2})
        valid = config['foo'].get(confuse.OneOf([
            confuse.String(),
            confuse.Integer(),
        ]))
        self.assertEqual(valid, 2)
github beetbox / confuse / test / test_valid.py View on Github external
def test_none_as_default(self):
        config = _root({})
        valid = config.get({'foo': confuse.Integer(None)})
        self.assertIsNone(valid['foo'])
github beetbox / confuse / test / test_valid.py View on Github external
def test_undeclared_key_ignored_from_input(self):
        config = _root({'foo': 5, 'bar': 6})
        valid = config.get({'foo': confuse.Integer()})
        with self.assertRaises(KeyError):
            valid['bar']
github beetbox / confuse / test / test_valid.py View on Github external
def test_nested_dict_template(self):
        config = _root({
            'foo': {'bar': 9},
        })
        valid = config.get({
            'foo': {'bar': confuse.Integer()},
        })
        self.assertEqual(valid['foo']['bar'], 9)
github buluba89 / Yatcobot / yatcobot / plugins / actions.py View on Github external
def get_config_template():
        template = {
            'enabled': confuse.TypeTemplate(bool),
            'keywords': confuse.StrSeq(),
            'max_following': confuse.Integer(),
            'multiple': confuse.TypeTemplate(bool)
        }
        return template
github buluba89 / Yatcobot / yatcobot / plugins / filters.py View on Github external
def get_config_template():
        template = {
            'enabled': confuse.TypeTemplate(bool),
            'number': confuse.Integer()
        }
        return template
github buluba89 / Yatcobot / yatcobot / config / __init__.py View on Github external
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(),
                'clear_queue_interval': confuse.Integer(),
                'rate_limit_update_interval': confuse.Integer(),