def test_load_local_config_error(mock_home, config_text, error_text): config_file = mock_home / WORKSPACE_CONFIG config_file.write_text(config_text) with pytest.raises(ConfigurationError) as e: load_local_config(mock_home) assert str(e.value).replace(str(mock_home), "/root") == error_text
def test_load_local_config_no_file(tmp_path): config = load_local_config(tmp_path) assert config == LocalConfig(hosts=None, push=None, pull=None, both=None, extends=None)
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, )