From aaa3a8ebdac0cb9d025fea6a96b8c06acc44ab9b Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 5 Mar 2025 18:39:29 -0800 Subject: [PATCH] style: Remove trailing whitespaces and fix code formatting --- tests/basic/test_main.py | 2 +- tests/basic/test_model_info_manager.py | 26 ++++++++++---------------- tests/basic/test_ssl_verification.py | 10 +++++----- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/tests/basic/test_main.py b/tests/basic/test_main.py index c01553903..1e9942c1a 100644 --- a/tests/basic/test_main.py +++ b/tests/basic/test_main.py @@ -683,7 +683,7 @@ class TestMain(TestCase): return_coder=True, ) self.assertTrue(coder.detect_urls) - + @patch("aider.models.ModelInfoManager.set_verify_ssl") def test_no_verify_ssl_sets_model_info_manager(self, mock_set_verify_ssl): with GitTemporaryDirectory(): diff --git a/tests/basic/test_model_info_manager.py b/tests/basic/test_model_info_manager.py index 4e90dfe71..468057f31 100644 --- a/tests/basic/test_model_info_manager.py +++ b/tests/basic/test_model_info_manager.py @@ -32,35 +32,31 @@ class TestModelInfoManager(TestCase): # Test with default verify_ssl=True self.manager._update_cache() - mock_get.assert_called_with( - self.manager.MODEL_INFO_URL, timeout=5, verify=True - ) + mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=True) # Test with verify_ssl=False mock_get.reset_mock() self.manager.set_verify_ssl(False) self.manager._update_cache() - mock_get.assert_called_with( - self.manager.MODEL_INFO_URL, timeout=5, verify=False - ) + mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=False) def test_lazy_loading_cache(self): # Create a cache file self.manager.cache_file.write_text('{"test_model": {"max_tokens": 4096}}') - + # Verify cache is not loaded on initialization self.assertFalse(self.manager._cache_loaded) self.assertIsNone(self.manager.content) - + # Access content through get_model_from_cached_json_db with patch.object(self.manager, "_update_cache") as mock_update: result = self.manager.get_model_from_cached_json_db("test_model") - + # Verify cache was loaded self.assertTrue(self.manager._cache_loaded) self.assertIsNotNone(self.manager.content) self.assertEqual(result, {"max_tokens": 4096}) - + # Verify _update_cache was not called since cache exists and is valid mock_update.assert_not_called() @@ -71,16 +67,14 @@ class TestModelInfoManager(TestCase): mock_response.status_code = 200 mock_response.json.return_value = {"test_model": {"max_tokens": 4096}} mock_get.return_value = mock_response - + # Set verify_ssl to False before any cache operations self.manager.set_verify_ssl(False) - + # Force cache update by making it look expired with patch("time.time", return_value=9999999999): # This should trigger _update_cache result = self.manager.get_model_from_cached_json_db("test_model") - + # Verify _update_cache was called with verify=False - mock_get.assert_called_with( - self.manager.MODEL_INFO_URL, timeout=5, verify=False - ) + mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=False) diff --git a/tests/basic/test_ssl_verification.py b/tests/basic/test_ssl_verification.py index 93a8e8fbf..8f2707fd6 100644 --- a/tests/basic/test_ssl_verification.py +++ b/tests/basic/test_ssl_verification.py @@ -36,14 +36,14 @@ class TestSSLVerification(TestCase): input=DummyInput(), output=DummyOutput(), ) - + # Verify model_info_manager.set_verify_ssl was called with False mock_set_verify_ssl.assert_called_once_with(False) - + # Verify httpx clients were created with verify=False mock_client.assert_called_once_with(verify=False) mock_async_client.assert_called_once_with(verify=False) - + # Verify SSL_VERIFY environment variable was set to empty string self.assertEqual(os.environ.get("SSL_VERIFY"), "") @@ -53,9 +53,9 @@ class TestSSLVerification(TestCase): with patch("aider.main.InputOutput"): with patch("aider.coders.Coder.create"): main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput()) - + # Verify model_info_manager.set_verify_ssl was not called mock_set_verify_ssl.assert_not_called() - + # Verify SSL_VERIFY environment variable was not set self.assertNotIn("SSL_VERIFY", os.environ)