Exemplo n.º 1
0
def test_load_global_config_error(mock_home, config_text, error_text):
    config_file = mock_home / GLOBAL_CONFIG
    config_file.parent.mkdir(parents=True)
    config_file.write_text(config_text)

    with pytest.raises(ConfigurationError) as e:
        load_global_config()

    assert str(e.value).replace(str(mock_home), "/root") == error_text
Exemplo n.º 2
0
def test_load_global_config(mock_home):
    config_file = mock_home / GLOBAL_CONFIG
    config_file.parent.mkdir(parents=True)
    config_file.write_text(
        """\
[general]
allow_uninitiated_workspaces = true
remote_root = "my-remotes"

[[hosts]]
host = "test-host.example.com"
default = true
label = "foo"

[push]
exclude = ["env", ".git"]

[pull]
exclude = ["src/generated"]

[both]
exclude = ["build"]
"""
    )

    config = load_global_config()
    assert config == GlobalConfig(
        hosts=[ConnectionConfig(host="test-host.example.com", directory=None, default=True, label="foo")],
        push=SyncRulesConfig(exclude=["env", ".git"]),
        pull=SyncRulesConfig(exclude=["src/generated"]),
        both=SyncRulesConfig(exclude=["build"]),
        general=GeneralConfig(allow_uninitiated_workspaces=True, remote_root="my-remotes"),
    )
Exemplo n.º 3
0
def test_load_global_config_no_file(mock_home):
    config = load_global_config()
    assert config == GlobalConfig(
        hosts=None,
        push=None,
        pull=None,
        both=None,
        general=GeneralConfig(allow_uninitiated_workspaces=False, remote_root=DEFAULT_REMOTE_ROOT),
    )