Пример #1
0
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', 'period': 60}]
Пример #2
0
def test_unnamed_check():
    conf = "checks: [{period: 1}]"
    with patch_conf(conf):
        conf = ReloadableSettings('::')
    assert conf.checks == [{
        'name': 'Unnamed check 1',
        'period': 1,
    }]
Пример #3
0
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)]
    }]
Пример #4
0
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)]
    }]
Пример #5
0
def test_empty_period():
    conf = "checks: [{name: x}]"
    with patch_conf(conf):
        conf = ReloadableSettings('::')
    assert conf.checks[0]['period'] == 300
Пример #6
0
def test_period_parse():
    conf = "checks: [{period: 1 hour}]"
    with patch_conf(conf):
        conf = ReloadableSettings('::')
    assert conf.checks[0]['period'] == 3600
Пример #7
0
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'
Пример #8
0
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'