refactor: replace sa.String with EnumText in mapped_column for type s… (#33332)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
tmimmanuel
2026-03-14 04:38:27 +00:00
committed by GitHub
parent 6043ec4423
commit e64f4d6039
40 changed files with 218 additions and 138 deletions

View File

@ -48,7 +48,7 @@ def make_message():
msg.query = "hello"
msg.re_sign_file_url_answer = ""
msg.user_feedback = MagicMock(rating=None)
msg.status = "success"
msg.status = "normal"
msg.error = None
return msg

View File

@ -137,7 +137,7 @@ def test_message_list_mapping(app: Flask) -> None:
{"id": "file-dict", "filename": "a.txt", "type": "file", "transfer_method": "local"},
message_file_obj,
],
status="success",
status="normal",
error=None,
message_metadata_dict={"meta": "value"},
extra_contents=[

View File

@ -3730,7 +3730,7 @@ class TestDatasetRetrievalAdditionalHelpers:
attachment_ids=None,
dataset_ids=["d1"],
app_id="a1",
user_from="web",
user_from="account",
user_id="u1",
)
mock_session.add_all.assert_not_called()
@ -3740,7 +3740,7 @@ class TestDatasetRetrievalAdditionalHelpers:
attachment_ids=["f1"],
dataset_ids=["d1", "d2"],
app_id="a1",
user_from="web",
user_from="account",
user_id="u1",
)
mock_session.add_all.assert_called()

View File

@ -5,6 +5,7 @@ from typing import Any
from unittest.mock import patch
from core.app.entities.app_invoke_entities import InvokeFrom
from core.helper.tool_parameter_cache import ToolParameterCache
from core.tools.__base.tool import Tool
from core.tools.__base.tool_runtime import ToolRuntime
from core.tools.entities.common_entities import I18nObject
@ -112,37 +113,38 @@ def test_encrypt_tool_parameters():
def test_decrypt_tool_parameters_cache_hit_and_miss():
manager = _build_manager()
with patch("core.tools.utils.configuration.ToolParameterCache") as cache_cls:
cache = cache_cls.return_value
cache.get.return_value = {"secret": "cached"}
with (
patch.object(ToolParameterCache, "get", return_value={"secret": "cached"}),
patch.object(ToolParameterCache, "set") as mock_set,
):
assert manager.decrypt_tool_parameters({"secret": "enc"}) == {"secret": "cached"}
cache.set.assert_not_called()
mock_set.assert_not_called()
with patch("core.tools.utils.configuration.ToolParameterCache") as cache_cls:
cache = cache_cls.return_value
cache.get.return_value = None
with patch("core.tools.utils.configuration.encrypter.decrypt_token", return_value="dec"):
decrypted = manager.decrypt_tool_parameters({"secret": "enc", "plain": "x"})
assert decrypted["secret"] == "dec"
cache.set.assert_called_once()
with (
patch.object(ToolParameterCache, "get", return_value=None),
patch.object(ToolParameterCache, "set") as mock_set,
patch("core.tools.utils.configuration.encrypter.decrypt_token", return_value="dec"),
):
decrypted = manager.decrypt_tool_parameters({"secret": "enc", "plain": "x"})
assert decrypted["secret"] == "dec"
mock_set.assert_called_once()
def test_delete_tool_parameters_cache():
manager = _build_manager()
with patch("core.tools.utils.configuration.ToolParameterCache") as cache_cls:
with patch.object(ToolParameterCache, "delete") as mock_delete:
manager.delete_tool_parameters_cache()
cache_cls.return_value.delete.assert_called_once()
mock_delete.assert_called_once()
def test_configuration_manager_decrypt_suppresses_errors():
manager = _build_manager()
with patch("core.tools.utils.configuration.ToolParameterCache") as cache_cls:
cache = cache_cls.return_value
cache.get.return_value = None
with patch("core.tools.utils.configuration.encrypter.decrypt_token", side_effect=RuntimeError("boom")):
decrypted = manager.decrypt_tool_parameters({"secret": "enc"})
with (
patch.object(ToolParameterCache, "get", return_value=None),
patch("core.tools.utils.configuration.encrypter.decrypt_token", side_effect=RuntimeError("boom")),
):
decrypted = manager.decrypt_tool_parameters({"secret": "enc"})
# decryption failure is suppressed, original value is retained.
assert decrypted["secret"] == "enc"

View File

@ -98,7 +98,7 @@ class TestAccountModelValidation:
)
# Assert
assert account.status == "active"
assert account.status == AccountStatus.ACTIVE
def test_account_get_status_method(self):
"""Test the get_status method returns AccountStatus enum."""
@ -106,7 +106,7 @@ class TestAccountModelValidation:
account = Account(
name="Test User",
email="test@example.com",
status="pending",
status=AccountStatus.PENDING,
)
# Act