Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
test: use real firecrawl auth responses (#43378)
Asuka Minato10c5da16f32d
diff --git a/api/tests/unit_tests/services/auth/test_firecrawl_auth.py b/api/tests/unit_tests/services/auth/test_firecrawl_auth.pyindex 9514d70ed48..d606cc7db97 100644--- a/api/tests/unit_tests/services/auth/test_firecrawl_auth.py+++ b/api/tests/unit_tests/services/auth/test_firecrawl_auth.py@@ -1,5 +1,4 @@-import json-from unittest.mock import MagicMock, patch+from unittest.mock import patchimport httpximport pytest@@ -65,10 +64,9 @@ class TestFirecrawlAuth:FirecrawlAuth(_credentials(api_key=""))@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)- def test_should_validate_valid_credentials_successfully(self, mock_post: MagicMock, auth_instance: FirecrawlAuth):+ def test_should_validate_valid_credentials_successfully(self, mock_post, auth_instance: FirecrawlAuth):"""Test successful credential validation"""- mock_response = MagicMock()- mock_response.status_code = 200+ mock_response = httpx.Response(200)mock_post.return_value = mock_responseresult = auth_instance.validate_credentials()@@ -96,13 +94,9 @@ class TestFirecrawlAuth:],)@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)- def test_should_handle_http_errors(- self, mock_post: MagicMock, status_code, error_message, auth_instance: FirecrawlAuth- ):+ def test_should_handle_http_errors(self, mock_post, status_code, error_message, auth_instance: FirecrawlAuth):"""Test handling of various HTTP error codes"""- mock_response = MagicMock()- mock_response.status_code = status_code- mock_response.json.return_value = {"error": error_message}+ mock_response = httpx.Response(status_code, json={"error": error_message})mock_post.return_value = mock_responsewith pytest.raises(DataSourceApiKeyAuthCredentialValidationError) as exc_info:@@ -113,11 +107,11 @@ class TestFirecrawlAuth:@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)def test_should_map_upstream_failure_to_provider_unavailable(self,- mock_post: MagicMock,+ mock_post,status_code: int,auth_instance: FirecrawlAuth,):- mock_response = MagicMock(status_code=status_code)+ mock_response = httpx.Response(status_code)mock_post.return_value = mock_responsewith pytest.raises(DataSourceApiKeyAuthProviderUnavailableError) as exc_info:@@ -139,7 +133,7 @@ class TestFirecrawlAuth:@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)def test_should_handle_unexpected_errors(self,- mock_post: MagicMock,+ mock_post,status_code,response_text,has_json_error,@@ -147,13 +141,10 @@ class TestFirecrawlAuth:auth_instance: FirecrawlAuth,):"""Test handling of unexpected errors with various response formats"""- mock_response = MagicMock()- mock_response.status_code = status_code- mock_response.text = response_textif has_json_error:- mock_response.json.side_effect = json.JSONDecodeError("Not JSON", "", 0)+ mock_response = httpx.Response(status_code, text=response_text)else:- mock_response.json.return_value = {"error": "Forbidden"}+ mock_response = httpx.Response(status_code, json={"error": "Forbidden"})mock_post.return_value = mock_responsewith pytest.raises(DataSourceApiKeyAuthCredentialValidationError) as exc_info:@@ -171,7 +162,7 @@ class TestFirecrawlAuth:)@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)def test_should_handle_network_errors(- self, mock_post: MagicMock, exception_type, exception_message, auth_instance: FirecrawlAuth+ self, mock_post, exception_type, exception_message, auth_instance: FirecrawlAuth):"""Test handling of various network-related errors including timeouts"""mock_post.side_effect = exception_type(exception_message)@@ -196,8 +187,7 @@ class TestFirecrawlAuth:@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)def test_should_use_custom_base_url_in_validation(self, mock_post):"""Test that custom base URL is used in validation and normalized"""- mock_response = MagicMock()- mock_response.status_code = 200+ mock_response = httpx.Response(200)mock_post.return_value = mock_responsefor base in ("https://custom.firecrawl.dev", "https://custom.firecrawl.dev/"):@@ -209,7 +199,7 @@ class TestFirecrawlAuth:assert mock_post.call_args[0][0] == "https://custom.firecrawl.dev/v1/crawl"@patch("services.data_source.auth.firecrawl.firecrawl.httpx.post", autospec=True)- def test_should_handle_timeout_with_retry_suggestion(self, mock_post: MagicMock, auth_instance: FirecrawlAuth):+ def test_should_handle_timeout_with_retry_suggestion(self, mock_post, auth_instance: FirecrawlAuth):"""Test that timeout errors are handled gracefully with appropriate error message"""mock_post.side_effect = httpx.TimeoutException("The request timed out after 30 seconds")