Ejemplo n.º 1
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"),
    )
Ejemplo n.º 2
0
def test_medium_generate_remote_directory(mock_home, workspace_config):
    medium = TomlConfigurationMedium()
    medium._global_config = GlobalConfig(general=GeneralConfig(
        allow_uninitiated_workspaces=False, remote_root="my-root-for-test"), )
    generated_dir = medium.generate_remote_directory(workspace_config)

    assert str(generated_dir).startswith("my-root-for-test/workspace_")
Ejemplo n.º 3
0
def test_save_global_config(mock_home):
    save_global_config(
        GlobalConfig(
            hosts=[
                ConnectionConfig(host="test-host.example.com",
                                 directory=None,
                                 default=True)
            ],
            push=SyncRulesConfig(exclude=["env", ".git"]),
            pull=SyncRulesConfig(exclude=["src/generated"]),
            both=SyncRulesConfig(exclude=["build"]),
            general=GeneralConfig(allow_uninitiated_workspaces=True,
                                  remote_root="my-remotes"),
        ))

    assert ((mock_home / GLOBAL_CONFIG).read_text() == """\
[[hosts]]
host = "test-host.example.com"
default = true

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

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

[both]
exclude = [ "build",]

[general]
allow_uninitiated_workspaces = true
use_relative_remote_paths = false
remote_root = "my-remotes"
""")
Ejemplo n.º 4
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),
    )
Ejemplo n.º 5
0
def test_medium_is_workspace_root(mock_home):
    medium = TomlConfigurationMedium()
    global_config = GlobalConfig(general=GeneralConfig(
        allow_uninitiated_workspaces=False, remote_root="my-root-for-test"), )
    medium._global_config = global_config

    test_workspace = mock_home / "foo" / "bar"
    test_workspace.mkdir(parents=True)

    # No config - isn't workspace
    assert not medium.is_workspace_root(test_workspace)

    # Can find config - is workspace
    (test_workspace / WORKSPACE_CONFIG).write_text("[push]")
    assert medium.is_workspace_root(test_workspace)

    # No config, but uninitiated workspaces allowed - is workspace
    (test_workspace / WORKSPACE_CONFIG).unlink()
    global_config.general.allow_uninitiated_workspaces = True
    assert medium.is_workspace_root(test_workspace)