Beispiel #1
0
def test_merge():
    s = SettingsData(1, {
        "settings": [{
            "foo": 1
        }],
    })
    s.merge({"settings": [{"foo": 2}]})
    assert s._data, {"settings": [{"foo": 2}]}
Beispiel #2
0
def test_error_notifications_when_it_is_present_and_disabled():
    s = SettingsData(1, {
        "settings": [{
            "name": "errors",
            "enabled": False,
        }],
    })
    assert not s.error_notifications()
Beispiel #3
0
def test_apm_host_when_the_apm_setting_is_present_without_endpoint():
    s = SettingsData(1, {
        "settings": [{
            "name": "apm",
            "enabled": True,
        }],
    })
    assert s.apm_host() is None
Beispiel #4
0
def test_performance_stats_when_it_is_present_and_enabled():
    s = SettingsData(1, {
        "settings": [{
            "name": "apm",
            "enabled": True,
        }],
    })
    assert s.performance_stats()
Beispiel #5
0
def test_apm_host_when_the_apm_setting_is_present():
    s = SettingsData(
        1, {
            "settings": [{
                "name": "apm",
                "enabled": True,
                "endpoint": "http://api.example.com",
            }],
        })
    assert s.apm_host() == "http://api.example.com"
Beispiel #6
0
def test_config_route_when_it_is_empty():
    s = SettingsData(1, {"config_route": ""})
    assert s.config_route("http://example.com") == (
        "http://example.com/2020-06-18/config/1/config.json")
Beispiel #7
0
def test_config_route_when_the_given_host_ends_with_a_trailing_slash():
    s = SettingsData(1, {})
    assert s.config_route("http://example.com/") == (
        "http://example.com/2020-06-18/config/1/config.json")
Beispiel #8
0
def test_config_route_when_it_is_specified():
    s = SettingsData(1, {"config_route": "123/cfg/321/cfg.json"})
    assert s.config_route("http://example.com") == (
        "http://example.com/123/cfg/321/cfg.json")
Beispiel #9
0
def test_interval_when_no_poll_sec():
    s = SettingsData(1, {})
    assert s.interval() == 600
Beispiel #10
0
def test_performance_stats_when_settings_are_missing():
    s = SettingsData(1, {})
    assert s.performance_stats()
Beispiel #11
0
def test_error_notifications_when_settings_are_missing():
    s = SettingsData(1, {})
    assert s.error_notifications()
Beispiel #12
0
def test_interval_when_poll_sec_is_zero():
    s = SettingsData(1, {"poll_sec": 0})
    assert s.interval() == 600
Beispiel #13
0
def test_apm_host_when_the_apm_setting_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.apm_host() is None
Beispiel #14
0
def test_error_host_when_the_errors_setting_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.error_host() is None
Beispiel #15
0
def test_error_notifications_when_it_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.error_notifications()
Beispiel #16
0
def test_interval_when_poll_sec_is_None():
    s = SettingsData(1, {"poll_sec": None})
    assert s.interval() == 600
Beispiel #17
0
def test_interval_when_poll_sec_is_greater_than_zero():
    s = SettingsData(1, {"poll_sec": 123})
    assert s.interval() == 123
Beispiel #18
0
def test_config_route_when_missing():
    s = SettingsData(1, {})
    assert s.config_route("http://example.com") == (
        "http://example.com/2020-06-18/config/1/config.json")
Beispiel #19
0
def test_performance_stats_when_it_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.performance_stats()