コード例 #1
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_job_configs_override_globals():
    """make sure that passed job config stuff properly
    overrides global values """
    # stuff some new values to globals that we can overwrite...
    gtoml = """
    configs_dir = "/etc/globals"
    rsync_command = "/usr/not/really/here"
    verbose = false
    dry_run = false
    console_override = false
    capture_file = "Nobody_asked_me.txt"
    logging_level = "warning"
    override_rsync_params = ['a', 'b', 'c']
    added_rsync_params = ['way', 'down', 'south']
    global_excludes = ["nobody", "said", "anything"]
    """
    g = config._make_global_config(config.parse_string(gtoml))
    m = config._make_job_config(config.parse_string(override_jtoml))
    merged = config.merge_configs(g, m)
    assert merged.get(
        "verbose") is True, "'verbose' didn't overwrite defaults properly"
    assert merged.get(
        "dry_run") is True, "'dry_run' didn't overwrite defaults properly"
    assert (merged.get("logging_level") == "error"
            ), "'logging_level' didn't overwrite defaults properly"
    assert (merged.get("console_override") is
            True), "'console_override' didn't overwrite defaults properly"
    assert (merged.get("capture_file") == "my_rsyncr_output.txt"
            ), "'capture_file' didn't overwrite defaults properly"
コード例 #2
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_globals_override_defaults():
    """make sure that set global config options override defaults"""
    g = config._make_global_config(config.parse_string(override_gtoml))
    merged = config.merge_configs(globalconf=g)

    assert (merged["rsync_command"] == "/usr/local/bin/rsync"
            ), "rsync_command didn't override right"
    assert merged["verbose"] is True, "verbose didn't override right"
    assert merged["dry_run"] is True, "dry_run didn't override right"
    assert merged[
        "console_override"] is True, "console_override didn't override right"
    assert (merged["capture_file"] == "my_rsyncr_output.txt"
            ), "capture_file didn't override right"
    assert merged["global_rsync_params"] == [
        "1",
        "2",
        "3",
    ], "override_rsync_params didn't override right"
    assert merged["global_excludes"] == [
        "these",
        "are",
        "excluded",
    ], "global_excludes didn't override right"
    assert merged[
        "logging_level"] == "error", "logging_level didn't override right"

    # one for added rsyncs instead of override rsyncs
    gtoml = """added_rsync_params = ['one', 'two']"""
    g = config._make_global_config(config.parse_string(gtoml))
    merged = config.merge_configs(globalconf=g)
    assert ("two" in merged["global_rsync_params"]
            and "--delete" in merged["global_rsync_params"]
            ), "added_rsync_params didn't override right"
コード例 #3
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_excludes_accumulate():
    """make sure that excludes accumulate and don't overwrite..."""
    # just test it's getting values from job config first...
    g = config._make_global_config(config.parse_string(override_gtoml))
    m = config._make_job_config(config.parse_string(override_jtoml))
    merged = config.merge_configs(g, m)
    assert merged["excludes"] == ["nasty", "canasta"]
    # now test accumulation...
    merged = config.merge_configs(
        {}, m)  # let's not override defaults for this one
    cmd_list = run.build_command(merged, "bogus")
    for t in ("nasty", "canasta", "doc", "man"):
        assert f"--exclude={t}" in cmd_list, "malformed commandline exclude!"
コード例 #4
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_job_configs_override_defaults():
    """make sure that passed job config stuff properly
    overrides default values """
    g = config._make_global_config(config.parse_string(override_gtoml))
    m = config._make_job_config(config.parse_string(override_jtoml))
    merged = config.merge_configs(g, m)
    assert merged.get(
        "verbose") is True, "'verbose' didn't overwrite defaults properly"
    assert merged.get(
        "dry_run") is True, "'dry_run' didn't overwrite defaults properly"
    assert (merged.get("logging_level") == "error"
            ), "'logging_level' didn't overwrite defaults properly"
    assert (merged.get("console_override") is
            True), "'console_override' didn't overwrite defaults properly"
    assert (merged.get("capture_file") == "my_rsyncr_output.txt"
            ), "'capture_file' didn't overwrite defaults properly"
コード例 #5
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_accumulated_rsync_params():
    """make sure that rsync params can be ADDED to defaults"""
    gtoml = """added_rsync_params = ['--quiet', '--checksum']"""
    jtoml = """
target_root = "/path/to/my/backups/"
host = "pasilla:"

[sources.tst]
location = "/usr/local/share/"
target = "usr.local.share"
"""
    g = config._make_global_config(config.parse_string(gtoml))
    m = config._make_job_config(config.parse_string(jtoml))
    c = {}
    merged = config.merge_configs(g, m, c)
    # check defaults are still there
    assert ("--delete" in merged["global_rsync_params"]
            ), "Oops; default rsync param --delete is missing!"
    # check also that our added thing is there
    assert ("--quiet" in merged["global_rsync_params"]
            ), "Oops; added rsync param --quiet is missing!"
コード例 #6
0
ファイル: test_config.py プロジェクト: mfeif/rsyncr-backups
def test_global_excludes_overwrite():
    """exclude clauses in global configs should replace default values, and
    job configs should completely replace globally defined ones"""
    g = config._make_global_config(config.parse_string(override_gtoml))
    merged = config.merge_configs(g)
    assert merged["global_excludes"] == ["these", "are", "excluded"]