| 91 | |
| 92 | |
| 93 | class TestFileWriteTool(unittest.TestCase): |
| 94 | def setUp(self): |
| 95 | self.tool = FileWriteTool() |
| 96 | |
| 97 | def test_write_new_file(self): |
| 98 | with tempfile.TemporaryDirectory() as tmpdir: |
| 99 | path = Path(tmpdir) / "test.txt" |
| 100 | result = self.tool.execute({"path": str(path), "content": "hello world"}) |
| 101 | self.assertFalse(result.is_error) |
| 102 | self.assertEqual(path.read_text(), "hello world") |
| 103 | |
| 104 | def test_write_creates_directories(self): |
| 105 | with tempfile.TemporaryDirectory() as tmpdir: |
| 106 | path = Path(tmpdir) / "sub" / "dir" / "test.txt" |
| 107 | result = self.tool.execute({"path": str(path), "content": "nested"}) |
| 108 | self.assertFalse(result.is_error) |
| 109 | self.assertTrue(path.exists()) |
| 110 | |
| 111 | |
| 112 | class TestFileEditTool(unittest.TestCase): |
nothing calls this directly
no outgoing calls
no test coverage detected