From 710484386a9a9343fb074c9391d85fae67a4f036 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 25 Aug 2024 08:26:00 -0700 Subject: [PATCH] fix: Mock file system operations in test_get_model_info --- tests/basic/test_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/basic/test_models.py b/tests/basic/test_models.py index 6c6fed1f3..11aaaeabd 100644 --- a/tests/basic/test_models.py +++ b/tests/basic/test_models.py @@ -35,10 +35,12 @@ class TestModels(unittest.TestCase): @patch("aider.models.safe_read_json") @patch("aider.models.safe_write_json") @patch("requests.get") - def test_get_model_info(self, mock_get, mock_write_json, mock_read_json, mock_stat, mock_home): + @patch("aider.models.Path.mkdir") + def test_get_model_info(self, mock_mkdir, mock_get, mock_write_json, mock_read_json, mock_stat, mock_home): # Setup mock_home.return_value = Path("/mock/home") - mock_stat.return_value.st_mtime = time.time() - 86400 * 2 # 2 days old + mock_stat.return_value = unittest.mock.Mock(st_mtime=time.time() - 86400 * 2) # 2 days old + mock_mkdir.return_value = None # Ensure mkdir doesn't raise an exception # Test case 1: Cache exists and is fresh mock_read_json.return_value = {"test_model": {"info": "cached"}}