Fix basedpyright type errors (#25435)
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3278,7 +3278,7 @@ class TestRegisterService:
|
||||
redis_client.setex(cache_key, 24 * 60 * 60, account_id)
|
||||
|
||||
# Execute invitation retrieval
|
||||
result = RegisterService._get_invitation_by_token(
|
||||
result = RegisterService.get_invitation_by_token(
|
||||
token=token,
|
||||
workspace_id=workspace_id,
|
||||
email=email,
|
||||
@@ -3316,7 +3316,7 @@ class TestRegisterService:
|
||||
redis_client.setex(token_key, 24 * 60 * 60, json.dumps(invitation_data))
|
||||
|
||||
# Execute invitation retrieval
|
||||
result = RegisterService._get_invitation_by_token(token=token)
|
||||
result = RegisterService.get_invitation_by_token(token=token)
|
||||
|
||||
# Verify result contains expected data
|
||||
assert result is not None
|
||||
|
||||
@@ -14,6 +14,7 @@ from core.app.app_config.entities import (
|
||||
VariableEntityType,
|
||||
)
|
||||
from core.model_runtime.entities.llm_entities import LLMMode
|
||||
from core.prompt.utils.prompt_template_parser import PromptTemplateParser
|
||||
from models.account import Account, Tenant
|
||||
from models.api_based_extension import APIBasedExtension
|
||||
from models.model import App, AppMode, AppModelConfig
|
||||
@@ -37,7 +38,7 @@ class TestWorkflowConverter:
|
||||
# Setup default mock returns
|
||||
mock_encrypter.decrypt_token.return_value = "decrypted_api_key"
|
||||
mock_prompt_transform.return_value.get_prompt_template.return_value = {
|
||||
"prompt_template": type("obj", (object,), {"template": "You are a helpful assistant {{text_input}}"})(),
|
||||
"prompt_template": PromptTemplateParser(template="You are a helpful assistant {{text_input}}"),
|
||||
"prompt_rules": {"human_prefix": "Human", "assistant_prefix": "Assistant"},
|
||||
}
|
||||
mock_agent_chat_config_manager.get_app_config.return_value = self._create_mock_app_config()
|
||||
|
||||
@@ -1370,8 +1370,8 @@ class TestRegisterService:
|
||||
account_id="user-123", email="test@example.com"
|
||||
)
|
||||
|
||||
with patch("services.account_service.RegisterService._get_invitation_by_token") as mock_get_invitation_by_token:
|
||||
# Mock the invitation data returned by _get_invitation_by_token
|
||||
with patch("services.account_service.RegisterService.get_invitation_by_token") as mock_get_invitation_by_token:
|
||||
# Mock the invitation data returned by get_invitation_by_token
|
||||
invitation_data = {
|
||||
"account_id": "user-123",
|
||||
"email": "test@example.com",
|
||||
@@ -1503,12 +1503,12 @@ class TestRegisterService:
|
||||
assert result == "member_invite:token:test-token"
|
||||
|
||||
def test_get_invitation_by_token_with_workspace_and_email(self, mock_redis_dependencies):
|
||||
"""Test _get_invitation_by_token with workspace ID and email."""
|
||||
"""Test get_invitation_by_token with workspace ID and email."""
|
||||
# Setup mock
|
||||
mock_redis_dependencies.get.return_value = b"user-123"
|
||||
|
||||
# Execute test
|
||||
result = RegisterService._get_invitation_by_token("token-123", "workspace-456", "test@example.com")
|
||||
result = RegisterService.get_invitation_by_token("token-123", "workspace-456", "test@example.com")
|
||||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
@@ -1517,7 +1517,7 @@ class TestRegisterService:
|
||||
assert result["workspace_id"] == "workspace-456"
|
||||
|
||||
def test_get_invitation_by_token_without_workspace_and_email(self, mock_redis_dependencies):
|
||||
"""Test _get_invitation_by_token without workspace ID and email."""
|
||||
"""Test get_invitation_by_token without workspace ID and email."""
|
||||
# Setup mock
|
||||
invitation_data = {
|
||||
"account_id": "user-123",
|
||||
@@ -1527,19 +1527,19 @@ class TestRegisterService:
|
||||
mock_redis_dependencies.get.return_value = json.dumps(invitation_data).encode()
|
||||
|
||||
# Execute test
|
||||
result = RegisterService._get_invitation_by_token("token-123")
|
||||
result = RegisterService.get_invitation_by_token("token-123")
|
||||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert result == invitation_data
|
||||
|
||||
def test_get_invitation_by_token_no_data(self, mock_redis_dependencies):
|
||||
"""Test _get_invitation_by_token with no data."""
|
||||
"""Test get_invitation_by_token with no data."""
|
||||
# Setup mock
|
||||
mock_redis_dependencies.get.return_value = None
|
||||
|
||||
# Execute test
|
||||
result = RegisterService._get_invitation_by_token("token-123")
|
||||
result = RegisterService.get_invitation_by_token("token-123")
|
||||
|
||||
# Verify results
|
||||
assert result is None
|
||||
|
||||
Reference in New Issue
Block a user