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"), )
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" """)
def test_load_local_config_with_extensions(tmp_path): config_file = tmp_path / WORKSPACE_CONFIG config_file.write_text( """\ [[extends.hosts]] host = "test-host.example.com" directory = ".remotes/workspace" [extends.push] exclude = ["env", ".git"] include = ["env"] [both] exclude = ["build"] """ ) config = load_local_config(tmp_path) assert config == LocalConfig( hosts=None, push=None, pull=None, both=SyncRulesConfig(exclude=["build"]), extends=WorkCycleConfig( hosts=[ConnectionConfig(host="test-host.example.com", directory=".remotes/workspace", default=False)], push=SyncRulesConfig(exclude=["env", ".git"], include=["env"]), pull=None, both=None, ), )
def test_load_local_config(tmp_path): config_file = tmp_path / WORKSPACE_CONFIG config_file.write_text("""\ [[hosts]] host = "test-host.example.com" directory = ".remotes/workspace" [[hosts]] host = "other-host.example.com" directory = ".remotes/other-workspace" default = true [push] exclude = ["env", ".git"] include = ["env"] [pull] exclude = ["src/generated"] [both] exclude = ["build", "configs/global"] include = ["configs/global"] """) config = load_local_config(tmp_path) assert config == LocalConfig( hosts=[ ConnectionConfig(host="test-host.example.com", directory=".remotes/workspace", default=False), ConnectionConfig(host="other-host.example.com", directory=".remotes/other-workspace", default=True), ], push=SyncRulesConfig(exclude=["env", ".git"], include=["env"]), pull=SyncRulesConfig(exclude=["src/generated"]), both=SyncRulesConfig(exclude=["build", "configs/global"], include=["configs/global"]), extends=None, )