Skip to content

Commit 4dcb638

Browse files
test: fix test
1 parent 8e2cf7e commit 4dcb638

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

src/mcpm/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def main(ctx, help_flag, version):
9898
# Check if a command is being executed (and it's not help, no command, or the client command)
9999
if (
100100
ctx.invoked_subcommand
101-
and ctx.invoked_subcommand not in ["target", "client", "profile", "router"]
101+
and ctx.invoked_subcommand not in ["target", "client", "profile", "router", "share"]
102102
and not help_flag
103103
):
104104
# Check if active client is set

src/mcpm/commands/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"transfer",
1616
"router",
1717
"custom",
18+
"target",
1819
]
1920

2021
# All command modules

src/mcpm/commands/router.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def share(address, profile, http):
440440
# print share link
441441
console.print(f"[bold green]Router is sharing at {share_url}[/]")
442442
console.print(
443-
f"[green]Your profile can be accessed with the url {share_url}?profile={profile}{f'&s={api_key}' if api_key else ''}[/]\n"
443+
f"[green]Your profile can be accessed with the url {share_url}?{f's={api_key}&' if api_key else ''}profile={profile}[/]\n"
444444
)
445445
console.print(
446446
"[bold yellow]Be careful about the share link, it will be exposed to the public. Make sure to share to trusted users only.[/]"

src/mcpm/profile/profile_config.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
import os
34
from typing import Dict, Optional
45

@@ -8,6 +9,8 @@
89

910
DEFAULT_PROFILE_PATH = os.path.expanduser("~/.config/mcpm/profiles.json")
1011

12+
logger = logging.getLogger(__name__)
13+
1114

1215
class ProfileConfigManager:
1316
def __init__(self, profile_path: str = DEFAULT_PROFILE_PATH):
@@ -17,8 +20,12 @@ def __init__(self, profile_path: str = DEFAULT_PROFILE_PATH):
1720
def _load_profiles(self) -> Dict[str, list[ServerConfig]]:
1821
if not os.path.exists(self.profile_path):
1922
return {}
20-
with open(self.profile_path, "r", encoding="utf-8") as f:
21-
profiles = json.load(f) or {}
23+
try:
24+
with open(self.profile_path, "r", encoding="utf-8") as f:
25+
profiles = json.load(f) or {}
26+
except json.JSONDecodeError as e:
27+
logger.error(f"Error loading profiles from {self.profile_path}: {e}")
28+
return {}
2229
return {
2330
name: [TypeAdapter(ServerConfig).validate_python(config) for config in configs]
2431
for name, configs in profiles.items()

tests/test_add.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ def test_add_profile_to_client(windsurf_manager, monkeypatch):
213213
profile_name = "work"
214214
client_name = "windsurf"
215215

216+
monkeypatch.setattr(ClientRegistry, "get_active_target", Mock(return_value="@" + client_name))
216217
monkeypatch.setattr(ClientRegistry, "get_client_manager", Mock(return_value=windsurf_manager))
217-
monkeypatch.setattr(ClientRegistry, "get_active_client", Mock(return_value=client_name))
218218
monkeypatch.setattr(ClientRegistry, "get_active_client_manager", Mock(return_value=windsurf_manager))
219219
monkeypatch.setattr(ConfigManager, "get_router_config", Mock(return_value={"host": "localhost", "port": 8080}))
220220

221221
# test cli
222222
runner = CliRunner()
223223
result = runner.invoke(add, ["%" + profile_name, "--force", "--alias", "work"])
224224
assert result.exit_code == 0
225-
assert "Successfully added profile: work" in result.output
225+
assert "Successfully added profile %work to windsurf!" in result.output

tests/test_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_client_edit_command_client_not_supported(monkeypatch):
151151

152152
# Check the result
153153
assert result.exit_code == 0
154-
mock_print_error.assert_called_once_with("Unsupported")
154+
mock_print_error.assert_called_once_with()
155155

156156

157157
def test_client_edit_command_client_not_installed(monkeypatch):

0 commit comments

Comments
 (0)