mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
fix: Mock file system operations in test_get_model_info
This commit is contained in:
parent
6b0c98c799
commit
710484386a
1 changed files with 4 additions and 2 deletions
|
@ -35,10 +35,12 @@ class TestModels(unittest.TestCase):
|
||||||
@patch("aider.models.safe_read_json")
|
@patch("aider.models.safe_read_json")
|
||||||
@patch("aider.models.safe_write_json")
|
@patch("aider.models.safe_write_json")
|
||||||
@patch("requests.get")
|
@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
|
# Setup
|
||||||
mock_home.return_value = Path("/mock/home")
|
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
|
# Test case 1: Cache exists and is fresh
|
||||||
mock_read_json.return_value = {"test_model": {"info": "cached"}}
|
mock_read_json.return_value = {"test_model": {"info": "cached"}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue