from pathlib import Path from meine_app.projects import ( discover_profiles, load_project_config, project_profile_from_config, set_project_profile, ) def test_discover_profiles_lists_directories(tmp_path: Path): (tmp_path / "hai-agent-code").mkdir() (tmp_path / "uniagent").mkdir() (tmp_path / "not-a-dir.txt").write_text("x", encoding="utf-8") (tmp_path / ".hidden").mkdir() profiles = discover_profiles(tmp_path) assert profiles == ["hai-agent-code", "uniagent"] def test_project_profile_from_config_prefers_profile(): assert project_profile_from_config({"profile": "hai-agent-code"}) == "hai-agent-code" def test_project_profile_from_config_falls_back_to_ziel_agent(): assert project_profile_from_config({"ziel_agent": "uniagent"}) == "uniagent" def test_set_project_profile_writes_config(tmp_path: Path): project = tmp_path / "Demo" project.mkdir() config_path = set_project_profile(project, "hai-agent-code") config = load_project_config(project) assert config["profile"] == "hai-agent-code" assert "ziel_agent" not in config assert config_path.is_file()