mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
style: Remove trailing whitespaces and fix code formatting
This commit is contained in:
parent
9ceb766a67
commit
aaa3a8ebda
3 changed files with 16 additions and 22 deletions
|
@ -683,7 +683,7 @@ class TestMain(TestCase):
|
||||||
return_coder=True,
|
return_coder=True,
|
||||||
)
|
)
|
||||||
self.assertTrue(coder.detect_urls)
|
self.assertTrue(coder.detect_urls)
|
||||||
|
|
||||||
@patch("aider.models.ModelInfoManager.set_verify_ssl")
|
@patch("aider.models.ModelInfoManager.set_verify_ssl")
|
||||||
def test_no_verify_ssl_sets_model_info_manager(self, mock_set_verify_ssl):
|
def test_no_verify_ssl_sets_model_info_manager(self, mock_set_verify_ssl):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
|
|
|
@ -32,35 +32,31 @@ class TestModelInfoManager(TestCase):
|
||||||
|
|
||||||
# Test with default verify_ssl=True
|
# Test with default verify_ssl=True
|
||||||
self.manager._update_cache()
|
self.manager._update_cache()
|
||||||
mock_get.assert_called_with(
|
mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=True)
|
||||||
self.manager.MODEL_INFO_URL, timeout=5, verify=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# Test with verify_ssl=False
|
# Test with verify_ssl=False
|
||||||
mock_get.reset_mock()
|
mock_get.reset_mock()
|
||||||
self.manager.set_verify_ssl(False)
|
self.manager.set_verify_ssl(False)
|
||||||
self.manager._update_cache()
|
self.manager._update_cache()
|
||||||
mock_get.assert_called_with(
|
mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=False)
|
||||||
self.manager.MODEL_INFO_URL, timeout=5, verify=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_lazy_loading_cache(self):
|
def test_lazy_loading_cache(self):
|
||||||
# Create a cache file
|
# Create a cache file
|
||||||
self.manager.cache_file.write_text('{"test_model": {"max_tokens": 4096}}')
|
self.manager.cache_file.write_text('{"test_model": {"max_tokens": 4096}}')
|
||||||
|
|
||||||
# Verify cache is not loaded on initialization
|
# Verify cache is not loaded on initialization
|
||||||
self.assertFalse(self.manager._cache_loaded)
|
self.assertFalse(self.manager._cache_loaded)
|
||||||
self.assertIsNone(self.manager.content)
|
self.assertIsNone(self.manager.content)
|
||||||
|
|
||||||
# Access content through get_model_from_cached_json_db
|
# Access content through get_model_from_cached_json_db
|
||||||
with patch.object(self.manager, "_update_cache") as mock_update:
|
with patch.object(self.manager, "_update_cache") as mock_update:
|
||||||
result = self.manager.get_model_from_cached_json_db("test_model")
|
result = self.manager.get_model_from_cached_json_db("test_model")
|
||||||
|
|
||||||
# Verify cache was loaded
|
# Verify cache was loaded
|
||||||
self.assertTrue(self.manager._cache_loaded)
|
self.assertTrue(self.manager._cache_loaded)
|
||||||
self.assertIsNotNone(self.manager.content)
|
self.assertIsNotNone(self.manager.content)
|
||||||
self.assertEqual(result, {"max_tokens": 4096})
|
self.assertEqual(result, {"max_tokens": 4096})
|
||||||
|
|
||||||
# Verify _update_cache was not called since cache exists and is valid
|
# Verify _update_cache was not called since cache exists and is valid
|
||||||
mock_update.assert_not_called()
|
mock_update.assert_not_called()
|
||||||
|
|
||||||
|
@ -71,16 +67,14 @@ class TestModelInfoManager(TestCase):
|
||||||
mock_response.status_code = 200
|
mock_response.status_code = 200
|
||||||
mock_response.json.return_value = {"test_model": {"max_tokens": 4096}}
|
mock_response.json.return_value = {"test_model": {"max_tokens": 4096}}
|
||||||
mock_get.return_value = mock_response
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
# Set verify_ssl to False before any cache operations
|
# Set verify_ssl to False before any cache operations
|
||||||
self.manager.set_verify_ssl(False)
|
self.manager.set_verify_ssl(False)
|
||||||
|
|
||||||
# Force cache update by making it look expired
|
# Force cache update by making it look expired
|
||||||
with patch("time.time", return_value=9999999999):
|
with patch("time.time", return_value=9999999999):
|
||||||
# This should trigger _update_cache
|
# This should trigger _update_cache
|
||||||
result = self.manager.get_model_from_cached_json_db("test_model")
|
result = self.manager.get_model_from_cached_json_db("test_model")
|
||||||
|
|
||||||
# Verify _update_cache was called with verify=False
|
# Verify _update_cache was called with verify=False
|
||||||
mock_get.assert_called_with(
|
mock_get.assert_called_with(self.manager.MODEL_INFO_URL, timeout=5, verify=False)
|
||||||
self.manager.MODEL_INFO_URL, timeout=5, verify=False
|
|
||||||
)
|
|
||||||
|
|
|
@ -36,14 +36,14 @@ class TestSSLVerification(TestCase):
|
||||||
input=DummyInput(),
|
input=DummyInput(),
|
||||||
output=DummyOutput(),
|
output=DummyOutput(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify model_info_manager.set_verify_ssl was called with False
|
# Verify model_info_manager.set_verify_ssl was called with False
|
||||||
mock_set_verify_ssl.assert_called_once_with(False)
|
mock_set_verify_ssl.assert_called_once_with(False)
|
||||||
|
|
||||||
# Verify httpx clients were created with verify=False
|
# Verify httpx clients were created with verify=False
|
||||||
mock_client.assert_called_once_with(verify=False)
|
mock_client.assert_called_once_with(verify=False)
|
||||||
mock_async_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
|
# Verify SSL_VERIFY environment variable was set to empty string
|
||||||
self.assertEqual(os.environ.get("SSL_VERIFY"), "")
|
self.assertEqual(os.environ.get("SSL_VERIFY"), "")
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ class TestSSLVerification(TestCase):
|
||||||
with patch("aider.main.InputOutput"):
|
with patch("aider.main.InputOutput"):
|
||||||
with patch("aider.coders.Coder.create"):
|
with patch("aider.coders.Coder.create"):
|
||||||
main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput())
|
main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput())
|
||||||
|
|
||||||
# Verify model_info_manager.set_verify_ssl was not called
|
# Verify model_info_manager.set_verify_ssl was not called
|
||||||
mock_set_verify_ssl.assert_not_called()
|
mock_set_verify_ssl.assert_not_called()
|
||||||
|
|
||||||
# Verify SSL_VERIFY environment variable was not set
|
# Verify SSL_VERIFY environment variable was not set
|
||||||
self.assertNotIn("SSL_VERIFY", os.environ)
|
self.assertNotIn("SSL_VERIFY", os.environ)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue