def test_server_bad_config(tmpdir):
    good_conf = copy.deepcopy(config_dict)
    good_conf["storage"]["vault_path"] = str(tmpdir)

    for partial_conf in remove_each_key(good_conf):
        with pytest.raises(ConfigurationError):
            MainConfig(config_from_dict(partial_conf))

    bad_conf = {
        "log_level": "foo",
        "server": {
            "port": "-50",
            "prometheus_port": "bar",
            "connection_header_read_timeout": "-50"
        },
        "db": {
            "port": "0",
        },
        "storage": {
            "vault_path": "/certainly_doesnt_exist"
        },
        "replay": {
            "forced_end_time": "0",
            "grace_period": "-1",
            "delay": {
                "replay_delay": "-10",
                "update_interval": "0",
            },
            "merge": {
                "desired_quorum": -10,
                "stream_comparison_cutoff": -10,
            }
        },
    }

    for partially_bad_conf in replace_each_key(good_conf, bad_conf):
        with pytest.raises(ConfigurationError):
            MainConfig(config_from_dict(partially_bad_conf))
def delay_config(d):
    return DelayConfig(config_from_dict(d))
def merger_config(d):
    return MergerConfig(config_from_dict(d))
def replay_config(d):
    return ReplayConfig(config_from_dict(d))
def server_config(d):
    return MainConfig(config_from_dict(d))
def test_server_good_config(tmpdir):
    good_conf = copy.deepcopy(config_dict)
    good_conf["storage"]["vault_path"] = str(tmpdir)
    MainConfig(config_from_dict(good_conf))
    good_conf["log_level"] = 20
    MainConfig(config_from_dict(good_conf))