Exemplo n.º 1
0
def test_merge():
    s = SettingsData(1, {
        "settings": [{
            "foo": 1
        }],
    })
    s.merge({"settings": [{"foo": 2}]})
    assert s._data, {"settings": [{"foo": 2}]}
Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 4
0
def test_performance_stats_when_it_is_present_and_enabled():
    s = SettingsData(1, {
        "settings": [{
            "name": "apm",
            "enabled": True,
        }],
    })
    assert s.performance_stats()
Exemplo n.º 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"
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 9
0
def test_interval_when_no_poll_sec():
    s = SettingsData(1, {})
    assert s.interval() == 600
Exemplo n.º 10
0
def test_performance_stats_when_settings_are_missing():
    s = SettingsData(1, {})
    assert s.performance_stats()
Exemplo n.º 11
0
def test_error_notifications_when_settings_are_missing():
    s = SettingsData(1, {})
    assert s.error_notifications()
Exemplo n.º 12
0
def test_interval_when_poll_sec_is_zero():
    s = SettingsData(1, {"poll_sec": 0})
    assert s.interval() == 600
Exemplo n.º 13
0
def test_apm_host_when_the_apm_setting_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.apm_host() is None
Exemplo n.º 14
0
def test_error_host_when_the_errors_setting_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.error_host() is None
Exemplo n.º 15
0
def test_error_notifications_when_it_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.error_notifications()
Exemplo n.º 16
0
def test_interval_when_poll_sec_is_None():
    s = SettingsData(1, {"poll_sec": None})
    assert s.interval() == 600
Exemplo n.º 17
0
def test_interval_when_poll_sec_is_greater_than_zero():
    s = SettingsData(1, {"poll_sec": 123})
    assert s.interval() == 123
Exemplo n.º 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")
Exemplo n.º 19
0
def test_performance_stats_when_it_is_missing():
    s = SettingsData(1, {
        "settings": [],
    })
    assert s.performance_stats()