chore: remove dependency on func_timeout because LGPL (#31519)

This commit is contained in:
Maxime Beauchemin
2024-12-19 09:32:20 -08:00
committed by GitHub
parent db11a2a308
commit d8aba2f7e6
5 changed files with 12 additions and 19 deletions

View File

@@ -19,7 +19,6 @@ from unittest.mock import patch
import pytest
import yaml
from func_timeout import FunctionTimedOut
from sqlalchemy.exc import DBAPIError
from superset import db, event_logger, security_manager # noqa: F401
@@ -932,7 +931,7 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
== SupersetErrorType.GENERIC_DB_ENGINE_ERROR
)
@patch("superset.commands.database.test_connection.func_timeout")
@patch("superset.utils.core.timeout")
@patch("superset.commands.database.test_connection.event_logger.log_with_context")
@patch("superset.utils.core.g")
def test_connection_do_ping_timeout(
@@ -941,7 +940,11 @@ class TestTestConnectionDatabaseCommand(SupersetTestCase):
"""Test to make sure do_ping exceptions gets captured"""
database = get_example_database()
mock_g.user = security_manager.find_user("admin")
mock_func_timeout.side_effect = FunctionTimedOut("Time out")
mock_func_timeout.side_effect = SupersetTimeoutException(
error_type=SupersetErrorType.BACKEND_TIMEOUT_ERROR,
message="ERROR",
level=ErrorLevel.ERROR,
)
db_uri = database.sqlalchemy_uri_decrypted
json_payload = {"sqlalchemy_uri": db_uri}
command_without_db_name = TestConnectionDatabaseCommand(json_payload)