How to use the kibitzr.conf.ReloadableSettings function in kibitzr

To help you get started, we’ve selected a few kibitzr 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 kibitzr / kibitzr / tests / helpers.py View on Github external
import contextlib
import tempfile

from kibitzr.conf import ReloadableSettings
from kibitzr.stash import Stash

from .compat import mock


class SettingsMock(ReloadableSettings):

    def __init__(self):
        self.checks = []
        self.notifiers = {}
        self.creds = {'pass': 'password'}

    @classmethod
    def instance(cls):
        ReloadableSettings._instance = cls()
        return ReloadableSettings._instance

    @staticmethod
    def dispose():
        ReloadableSettings._instance = None
github kibitzr / kibitzr / tests / unit / test_conf.py View on Github external
def test_unnamed_check():
    conf = "checks: [{period: 1}]"
    with patch_conf(conf):
        conf = ReloadableSettings('::')
    assert conf.checks == [{
        'name': 'Unnamed check 1',
        'schedule': [TimelineRule(interval=1, unit='seconds', at=None)]
    }]
github kibitzr / kibitzr / tests / unit / test_conf.py View on Github external
def test_reread():
    conf1 = (
        "checks:\n"
        "  - name: Name\n"
        "    url: URL\n"
    )
    conf2 = conf1 + "    period: 60\n"
    with patch_creds(""):
        with patch_conf(conf1):
            conf = ReloadableSettings('::')
            # Config didn't change:
            assert not conf.reread()
        with patch_conf(conf2):
            # Config changed:
            assert conf.reread()
    assert conf.checks == [{
        'name': 'Name',
        'url': 'URL',
        'schedule': [TimelineRule(interval=60, unit='seconds', at=None)]
    }]
github kibitzr / kibitzr / tests / unit / test_conf.py View on Github external
def test_name_from_url_population():
    conf = "checks: [{url: 'http://example.com/page_name'}]"
    with patch_conf(conf):
        conf = ReloadableSettings('::')
    assert conf.checks[0]['name'] == 'http-example-com-page_name'
github kibitzr / kibitzr / tests / unit / test_conf.py View on Github external
def test_complex_conf_sample():
    with patch_conf(sample_conf):
        with patch_creds(sample_creds):
            conf = ReloadableSettings('::')
    assert conf.checks == checks
    assert conf.creds['mailgun']['url'] == 'ZZZ'
github kibitzr / kibitzr / kibitzr / conf.py View on Github external
def settings():
    """
    Returns singleton instance of settings
    """
    return ReloadableSettings.instance()