@@ -288,3 +288,50 @@ async def test_edit_contents_handler_empty_patches():
288
288
edit_results = json .loads (result [0 ].text )
289
289
assert edit_results ["test.txt" ]["result" ] == "error"
290
290
assert edit_results ["test.txt" ]["hash" ] is None
291
+
292
+
293
+ @pytest .mark .asyncio
294
+ async def test_get_contents_handler_legacy_missing_args ():
295
+ """Test GetTextFileContents handler with legacy single file request missing arguments."""
296
+ with pytest .raises (RuntimeError ) as exc_info :
297
+ await get_contents_handler .run_tool ({})
298
+ assert "Missing required argument: files" in str (exc_info .value )
299
+
300
+
301
+ @pytest .mark .asyncio
302
+ async def test_edit_contents_handler_missing_path ():
303
+ """Test EditTextFileContents handler with missing path in file operation."""
304
+ edit_args = {
305
+ "files" : [
306
+ {
307
+ "hash" : "any_hash" ,
308
+ "patches" : [{"contents" : "New content\n " }],
309
+ }
310
+ ]
311
+ }
312
+
313
+ with pytest .raises (RuntimeError ) as exc_info :
314
+ await edit_contents_handler .run_tool (edit_args )
315
+ assert "Missing required field: path" in str (exc_info .value )
316
+
317
+
318
+ @pytest .mark .asyncio
319
+ async def test_edit_contents_handler_missing_hash (tmp_path ):
320
+ """Test EditTextFileContents handler with missing hash in file operation."""
321
+ # Create a test file
322
+ test_file = tmp_path / "test.txt"
323
+ test_file .write_text ("test content" )
324
+
325
+ edit_args = {
326
+ "files" : [
327
+ {
328
+ "path" : str (test_file ),
329
+ "patches" : [{"contents" : "New content\n " }],
330
+ }
331
+ ]
332
+ }
333
+
334
+ result = await edit_contents_handler .run_tool (edit_args )
335
+ edit_results = json .loads (result [0 ].text )
336
+ assert edit_results [str (test_file )]["result" ] == "error"
337
+ assert "Missing required field: hash" in edit_results [str (test_file )]["reason" ]
0 commit comments