style: Remove trailing whitespaces and fix code formatting

This commit is contained in:
Paul Gauthier (aider) 2025-03-05 18:39:29 -08:00
parent 9ceb766a67
commit aaa3a8ebda
3 changed files with 16 additions and 22 deletions

View file

@ -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():

View file

@ -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)

View file

@ -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)