test: Mock offer_url to prevent URL opening in SSL verification tests

This commit is contained in:
Paul Gauthier (aider) 2025-03-05 18:44:47 -08:00
parent 96bde4ad03
commit 7132ae47d7

View file

@ -19,13 +19,16 @@ class TestSSLVerification(TestCase):
os.environ.clear() os.environ.clear()
os.environ.update(self.original_env) os.environ.update(self.original_env)
@patch("aider.io.InputOutput.offer_url")
@patch("aider.models.ModelInfoManager.set_verify_ssl") @patch("aider.models.ModelInfoManager.set_verify_ssl")
@patch("aider.llm.litellm._load_litellm") @patch("aider.llm.litellm._load_litellm")
@patch("httpx.Client") @patch("httpx.Client")
@patch("httpx.AsyncClient") @patch("httpx.AsyncClient")
def test_no_verify_ssl_flag_sets_model_info_manager( def test_no_verify_ssl_flag_sets_model_info_manager(
self, mock_async_client, mock_client, mock_load_litellm, mock_set_verify_ssl self, mock_async_client, mock_client, mock_load_litellm, mock_set_verify_ssl, mock_offer_url
): ):
# Prevent actual URL opening
mock_offer_url.return_value = False
# Mock the litellm._lazy_module to avoid AttributeError # Mock the litellm._lazy_module to avoid AttributeError
mock_load_litellm.return_value = None mock_load_litellm.return_value = None
mock_module = MagicMock() mock_module = MagicMock()
@ -57,8 +60,11 @@ class TestSSLVerification(TestCase):
# 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"), "")
@patch("aider.io.InputOutput.offer_url")
@patch("aider.models.model_info_manager.set_verify_ssl") @patch("aider.models.model_info_manager.set_verify_ssl")
def test_default_ssl_verification(self, mock_set_verify_ssl): def test_default_ssl_verification(self, mock_set_verify_ssl, mock_offer_url):
# Prevent actual URL opening
mock_offer_url.return_value = False
# Run main without --no-verify-ssl flag # Run main without --no-verify-ssl flag
with patch("aider.main.InputOutput"): with patch("aider.main.InputOutput"):
with patch("aider.coders.Coder.create"): with patch("aider.coders.Coder.create"):