1
+ """
2
+ Test for Qwen CLI manager
3
+ """
4
+
5
+ import os
6
+ import tempfile
7
+ from unittest .mock import patch
8
+
9
+ from mcpm .clients .managers .qwen_cli import QwenCliManager
10
+
11
+
12
+ def test_qwen_cli_manager_initialization ():
13
+ """Test QwenCliManager initialization"""
14
+ # Test with default config path
15
+ manager = QwenCliManager ()
16
+ assert manager .client_key == "qwen-cli"
17
+ assert manager .display_name == "Qwen CLI"
18
+ assert manager .download_url == "https://github.com/QwenLM/qwen-code"
19
+ assert manager .config_path == os .path .expanduser ("~/.qwen/settings.json" )
20
+
21
+ # Test with custom config path
22
+ custom_path = "/tmp/custom_settings.json"
23
+ manager = QwenCliManager (config_path_override = custom_path )
24
+ assert manager .config_path == custom_path
25
+
26
+
27
+ def test_qwen_cli_manager_get_empty_config ():
28
+ """Test QwenCliManager _get_empty_config method"""
29
+ manager = QwenCliManager ()
30
+ config = manager ._get_empty_config ()
31
+ assert "mcpServers" in config
32
+ assert "theme" in config
33
+ assert "selectedAuthType" in config
34
+ assert config ["mcpServers" ] == {}
35
+
36
+
37
+ def test_qwen_cli_manager_is_client_installed ():
38
+ """Test QwenCliManager is_client_installed method"""
39
+ manager = QwenCliManager ()
40
+
41
+ # Mock shutil.which to return a path (simulating installed client)
42
+ with patch ("shutil.which" , return_value = "/usr/local/bin/qwen" ):
43
+ assert manager .is_client_installed () is True
44
+
45
+ # Mock shutil.which to return None (simulating uninstalled client)
46
+ with patch ("shutil.which" , return_value = None ):
47
+ assert manager .is_client_installed () is False
48
+
49
+
50
+ def test_qwen_cli_manager_get_client_info ():
51
+ """Test QwenCliManager get_client_info method"""
52
+ manager = QwenCliManager ()
53
+ info = manager .get_client_info ()
54
+ assert info ["name" ] == "Qwen CLI"
55
+ assert info ["download_url" ] == "https://github.com/QwenLM/qwen-code"
56
+ assert info ["config_file" ] == os .path .expanduser ("~/.qwen/settings.json" )
57
+ assert info ["description" ] == "Alibaba's Qwen CLI tool"
0 commit comments