@@ -37,10 +37,10 @@ def cli(mock_ai_service, mock_token_usage):
3737 """Fixture for CommitLoom instance."""
3838 instance = CommitLoom (test_mode = True )
3939 # Mock git operations
40- instance .git .stage_files = MagicMock ()
41- instance .git .reset_staged_changes = MagicMock ()
42- instance .git .get_diff = MagicMock (return_value = "test diff" )
43- instance .ai_service .generate_commit_message = MagicMock (
40+ instance .git .stage_files = MagicMock () # type: ignore
41+ instance .git .reset_staged_changes = MagicMock () # type: ignore
42+ instance .git .get_diff = MagicMock (return_value = "test diff" ) # type: ignore
43+ instance .ai_service .generate_commit_message = MagicMock ( # type: ignore
4444 return_value = (
4545 MagicMock (title = "test" , body = {}, format_body = lambda : "test" ),
4646 mock_token_usage ,
@@ -71,7 +71,7 @@ def test_handle_commit_git_error(cli):
7171
7272def test_handle_commit_success (cli ):
7373 """Test successful commit."""
74- mock_file = GitFile ("test.py" , "A" , 100 , "abc123" )
74+ mock_file = GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )
7575 cli .git .get_staged_files = MagicMock (return_value = [mock_file ])
7676 cli .git .create_commit = MagicMock (return_value = True )
7777
@@ -82,7 +82,7 @@ def test_handle_commit_success(cli):
8282
8383def test_handle_commit_complex_changes (cli ):
8484 """Test handling complex changes."""
85- mock_files = [GitFile (f"test{ i } .py" , "A" , 100 , "abc123" ) for i in range (4 )]
85+ mock_files = [GitFile (f"test{ i } .py" , "A" , old_path = None , size = 100 , hash = "abc123" ) for i in range (4 )]
8686 cli .git .get_staged_files = MagicMock (return_value = mock_files )
8787 cli .git .create_commit = MagicMock (return_value = True )
8888
@@ -93,7 +93,7 @@ def test_handle_commit_complex_changes(cli):
9393
9494def test_handle_commit_user_abort (cli ):
9595 """Test user aborting commit."""
96- mock_file = GitFile ("test.py" , "A" , 100 , "abc123" )
96+ mock_file = GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )
9797 cli .git .get_staged_files = MagicMock (return_value = [mock_file ])
9898 with patch ("commitloom.cli.cli_handler.console" ) as mock_console :
9999 mock_console .confirm_action .return_value = False
@@ -107,7 +107,7 @@ def test_handle_commit_user_abort(cli):
107107
108108def test_handle_commit_with_flags (cli ):
109109 """Test commit with various flags."""
110- mock_file = GitFile ("test.py" , "A" , 100 , "abc123" )
110+ mock_file = GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )
111111 cli .git .get_staged_files = MagicMock (return_value = [mock_file ])
112112 cli .git .create_commit = MagicMock (return_value = True )
113113
@@ -118,7 +118,7 @@ def test_handle_commit_with_flags(cli):
118118
119119def test_handle_commit_api_error (cli ):
120120 """Test handling API error."""
121- mock_file = GitFile ("test.py" , "A" , 100 , "abc123" )
121+ mock_file = GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )
122122 cli .git .get_staged_files = MagicMock (return_value = [mock_file ])
123123 cli .ai_service .generate_commit_message = MagicMock (side_effect = Exception ("API error" ))
124124
@@ -131,9 +131,9 @@ def test_handle_commit_api_error(cli):
131131def test_create_batches_with_ignored_files (cli ):
132132 """Test batch creation with ignored files."""
133133 mock_files = [
134- GitFile ("test.py" , "A" , 100 , "abc123" ),
135- GitFile ("node_modules/test.js" , "A" , 100 , "def456" ),
136- GitFile ("test2.py" , "A" , 100 , "ghi789" ),
134+ GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" ),
135+ GitFile ("node_modules/test.js" , "A" , old_path = None , size = 100 , hash = "def456" ),
136+ GitFile ("test2.py" , "A" , old_path = None , size = 100 , hash = "ghi789" ),
137137 ]
138138 cli .git .get_staged_files = MagicMock (return_value = mock_files )
139139 cli .git .should_ignore_file = MagicMock (side_effect = lambda path : "node_modules" in path )
@@ -156,7 +156,7 @@ def test_create_batches_git_error(cli):
156156
157157def test_handle_batch_no_changes (cli ):
158158 """Test handling batch with no changes."""
159- mock_files = [GitFile ("test.py" , "A" , 100 , "abc123" )]
159+ mock_files = [GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )]
160160 cli .git .create_commit = MagicMock (return_value = False )
161161
162162 result = cli ._handle_batch (mock_files , 1 , 1 )
@@ -168,15 +168,15 @@ def test_create_combined_commit_success(cli):
168168 """Test successful creation of combined commit."""
169169 batches = [
170170 {
171- "files" : [GitFile ("test1.py" , "A" , 100 , "abc123" )],
171+ "files" : [GitFile ("test1.py" , "A" , old_path = None , size = 100 , hash = "abc123" )],
172172 "commit_data" : MagicMock (
173173 title = "test1" ,
174174 body = {"feat" : {"emoji" : "✨" , "changes" : ["change1" ]}},
175175 summary = "summary1" ,
176176 ),
177177 },
178178 {
179- "files" : [GitFile ("test2.py" , "A" , 100 , "def456" )],
179+ "files" : [GitFile ("test2.py" , "A" , old_path = None , size = 100 , hash = "def456" )],
180180 "commit_data" : MagicMock (
181181 title = "test2" ,
182182 body = {"fix" : {"emoji" : "🐛" , "changes" : ["change2" ]}},
@@ -195,7 +195,7 @@ def test_create_combined_commit_no_changes(cli):
195195 """Test combined commit with no changes."""
196196 batches = [
197197 {
198- "files" : [GitFile ("test1.py" , "A" , 100 , "abc123" )],
198+ "files" : [GitFile ("test1.py" , "A" , old_path = None , size = 100 , hash = "abc123" )],
199199 "commit_data" : MagicMock (
200200 title = "test1" ,
201201 body = {"feat" : {"emoji" : "✨" , "changes" : ["change1" ]}},
@@ -223,7 +223,7 @@ def test_debug_mode(cli):
223223
224224def test_process_files_in_batches_error (cli ):
225225 """Test error handling in batch processing."""
226- mock_files = [GitFile (f"test{ i } .py" , "A" , 100 , "abc123" ) for i in range (4 )]
226+ mock_files = [GitFile (f"test{ i } .py" , "A" , old_path = None , size = 100 , hash = "abc123" ) for i in range (4 )]
227227 cli .git .get_diff = MagicMock (side_effect = GitError ("Git error" ))
228228
229229 with pytest .raises (SystemExit ) as exc :
@@ -234,7 +234,7 @@ def test_process_files_in_batches_error(cli):
234234
235235def test_handle_batch_value_error (cli ):
236236 """Test handling value error in batch processing."""
237- mock_files = [GitFile ("test.py" , "A" , 100 , "abc123" )]
237+ mock_files = [GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )]
238238 cli .git .get_diff = MagicMock (side_effect = ValueError ("Invalid value" ))
239239
240240 result = cli ._handle_batch (mock_files , 1 , 1 )
@@ -244,7 +244,7 @@ def test_handle_batch_value_error(cli):
244244
245245def test_handle_batch_git_error (cli ):
246246 """Test handling git error in batch processing."""
247- mock_files = [GitFile ("test.py" , "A" , 100 , "abc123" )]
247+ mock_files = [GitFile ("test.py" , "A" , old_path = None , size = 100 , hash = "abc123" )]
248248 cli .git .get_diff = MagicMock (side_effect = GitError ("Git error" ))
249249
250250 result = cli ._handle_batch (mock_files , 1 , 1 )
0 commit comments