From 1a3e8b337543009fae012ace270c0a07b41d2152 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 2 Oct 2024 11:19:22 -0700 Subject: [PATCH] test: update sanity check test to use real Model instances --- tests/basic/test_models.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/basic/test_models.py b/tests/basic/test_models.py index 4ad4cafbe..531a317c1 100644 --- a/tests/basic/test_models.py +++ b/tests/basic/test_models.py @@ -62,25 +62,17 @@ class TestModels(unittest.TestCase): self.assertIn("- API_KEY1: Not set", str(calls)) self.assertIn("- API_KEY2: Not set", str(calls)) - @patch("aider.models.sanity_check_model") - def test_sanity_check_models_bogus_editor(self, mock_sanity_check_model): + def test_sanity_check_models_bogus_editor(self): mock_io = MagicMock() - main_model = MagicMock() - main_model.name = "gpt-4" - main_model.weak_model = None - main_model.editor_model = MagicMock() - main_model.editor_model.name = "bogus-model" + main_model = models.Model("gpt-4") + main_model.editor_model = models.Model("bogus-model") - # Set up mock to return False for main model and True (problem) for editor model - mock_sanity_check_model.side_effect = [False, True] + result = models.sanity_check_models(mock_io, main_model) - result = sanity_check_models(mock_io, main_model) - - self.assertTrue( - result - ) # Should return True because there's a problem with the editor model - mock_sanity_check_model.assert_called_with(mock_io, main_model.editor_model) + self.assertTrue(result) # Should return True because there's a problem with the editor model mock_io.tool_warning.assert_called_once() # Ensure a warning was issued + warning_message = mock_io.tool_warning.call_args[0][0] + self.assertIn("bogus-model", warning_message) # Check that the warning mentions the bogus model if __name__ == "__main__":