1+ """Tests for skill management refactoring changes."""
2+
3+ import pytest
4+ from unittest .mock import MagicMock , patch
5+ from code_assistant_manager .skills .manager import SkillManager
6+ from code_assistant_manager .skills .models import Skill
7+
8+
9+ class TestSkillManagementRefactoring :
10+ """Test the simplified skill management after refactoring."""
11+
12+ def test_skill_get_simplified (self ):
13+ """Test that skill.get() no longer supports install key format or complex lookup."""
14+ manager = SkillManager ()
15+
16+ # Test with a skill that doesn't exist
17+ result = manager .get ("nonexistent" )
18+ assert result is None
19+
20+ # The complex install key format lookup was removed
21+ # This should just do a simple dict lookup
22+ result = manager .get ("repo:directory" )
23+ assert result is None
24+
25+ def test_skill_delete_simplified (self ):
26+ """Test that skill.delete() no longer supports install key format."""
27+ manager = SkillManager ()
28+
29+ # Test deleting a non-existent skill - raises KeyError from dict del operation
30+ with pytest .raises (KeyError ):
31+ manager .delete ("nonexistent" )
32+
33+ # The complex install key format lookup was removed - still raises KeyError for simple keys
34+ with pytest .raises (KeyError ):
35+ manager .delete ("repo:directory" )
36+
37+ def test_skill_install_simplified (self ):
38+ """Test that skill.install() no longer supports install key format."""
39+ manager = SkillManager ()
40+
41+ # Test installing a non-existent skill
42+ with pytest .raises (ValueError , match = "Skill with key 'nonexistent' not found" ):
43+ manager .install ("nonexistent" , "claude" )
44+
45+ # The complex install key format lookup was removed
46+ with pytest .raises (ValueError , match = "Skill with key 'repo:directory' not found" ):
47+ manager .install ("repo:directory" , "claude" )
48+
49+ def test_skill_uninstall_simplified (self ):
50+ """Test that skill.uninstall() no longer supports install key format."""
51+ manager = SkillManager ()
52+
53+ # Test uninstalling a non-existent skill
54+ with pytest .raises (ValueError , match = "Skill with key 'nonexistent' not found" ):
55+ manager .uninstall ("nonexistent" , "claude" )
56+
57+ # The complex install key format lookup was removed
58+ with pytest .raises (ValueError , match = "Skill with key 'repo:directory' not found" ):
59+ manager .uninstall ("repo:directory" , "claude" )
60+
61+
62+ class TestSkillCLICommandsRefactoring :
63+ """Test the simplified skill CLI commands after refactoring."""
64+
65+ @pytest .fixture
66+ def runner (self ):
67+ """Create CLI test runner."""
68+ from typer .testing import CliRunner
69+ return CliRunner ()
70+
71+ def test_list_skills_no_query_parameter (self , runner ):
72+ """Test that list command no longer has --query parameter."""
73+ from code_assistant_manager .cli .app import app
74+
75+ # This should work without --query parameter
76+ with patch ('code_assistant_manager.cli.skills_commands.SkillManager' ) as mock_manager :
77+ mock_instance = MagicMock ()
78+ mock_instance .get_all .return_value = {}
79+ mock_manager .return_value = mock_instance
80+
81+ result = runner .invoke (app , ["skill" , "list" ])
82+ # Command should still work (even if it shows no skills)
83+ assert result .exit_code in [0 , 1 ] # 0 for success, 1 for error
84+
85+ def test_skill_install_help_still_mentions_qwen_inconsistency (self , runner ):
86+ """Test that skill install help still mentions Qwen (inconsistency after refactoring)."""
87+ from code_assistant_manager .cli .app import app
88+
89+ result = runner .invoke (app , ["skill" , "install" , "--help" ])
90+ assert result .exit_code == 0
91+ # Qwen is still mentioned in individual command help (inconsistency)
92+ assert "qwen" in result .output .lower ()
93+
94+ def test_skill_uninstall_help_still_mentions_qwen_inconsistency (self , runner ):
95+ """Test that skill uninstall help still mentions Qwen (inconsistency after refactoring)."""
96+ from code_assistant_manager .cli .app import app
97+
98+ result = runner .invoke (app , ["skill" , "uninstall" , "--help" ])
99+ assert result .exit_code == 0
100+ # Qwen is still mentioned in individual command help (inconsistency)
101+ assert "qwen" in result .output .lower ()
102+
103+ def test_skill_status_help_still_mentions_qwen_inconsistency (self , runner ):
104+ """Test that skill status help still mentions Qwen (inconsistency after refactoring)."""
105+ from code_assistant_manager .cli .app import app
106+
107+ result = runner .invoke (app , ["skill" , "status" , "--help" ])
108+ assert result .exit_code == 0
109+ # Qwen is still mentioned in individual command help (inconsistency)
110+ assert "qwen" in result .output .lower ()
111+
112+ def test_skill_uninstall_all_help_still_mentions_qwen_inconsistency (self , runner ):
113+ """Test that skill uninstall-all help still mentions Qwen (inconsistency after refactoring)."""
114+ from code_assistant_manager .cli .app import app
115+
116+ result = runner .invoke (app , ["skill" , "uninstall-all" , "--help" ])
117+ assert result .exit_code == 0
118+ # Qwen is still mentioned in individual command help (inconsistency)
119+ assert "qwen" in result .output .lower ()
120+
121+
122+ class TestCompletionScriptsRefactoring :
123+ """Test that completion scripts were properly refactored."""
124+
125+ def test_completion_scripts_still_include_qwen_in_tools (self ):
126+ """Test that completion scripts still include Qwen in tools list (inconsistency after refactoring)."""
127+ from code_assistant_manager .cli .app import _get_bash_completion_content
128+
129+ completion_script = _get_bash_completion_content ()
130+
131+ # The completion scripts still include "qwen" in the tools list
132+ # even though Qwen skill support was removed
133+ assert 'qwen' in completion_script , "Completion scripts still include 'qwen' in tools list after skill support removal"
134+
135+ # But Qwen is NOT in the supported app types for skills
136+ from code_assistant_manager .skills import VALID_APP_TYPES
137+ assert "qwen" not in VALID_APP_TYPES , "Qwen should not be in VALID_APP_TYPES"
138+
139+ def test_completion_scripts_include_qwen_in_mcp_clients (self ):
140+ """Test that completion scripts include Qwen in MCP client lists."""
141+ from code_assistant_manager .cli .app import _get_bash_completion_content
142+
143+ completion_script = _get_bash_completion_content ()
144+
145+ # Qwen should still be included in MCP client completion options
146+ # since MCP support for Qwen may still exist
147+ assert '--client -c --interactive -i --help' in completion_script
148+ # This tests that the MCP client options are still present
0 commit comments