use deco to avoid current_user (#26077)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Asuka Minato
2025-10-16 15:45:51 +09:00
committed by GitHub
parent bd01af6415
commit cced33d068
109 changed files with 526 additions and 788 deletions

View File

@@ -8,7 +8,7 @@ from werkzeug.exceptions import Unauthorized
from configs import dify_config
from controllers.console.error import AccountNotFound, NotAllowedCreateWorkspace
from models.account import AccountStatus, TenantAccountJoin
from models import AccountStatus, TenantAccountJoin
from services.account_service import AccountService, RegisterService, TenantService, TokenPair
from services.errors.account import (
AccountAlreadyInTenantError,
@@ -470,7 +470,7 @@ class TestAccountService:
# Verify integration was created
from extensions.ext_database import db
from models.account import AccountIntegrate
from models import AccountIntegrate
integration = db.session.query(AccountIntegrate).filter_by(account_id=account.id, provider="new-google").first()
assert integration is not None
@@ -505,7 +505,7 @@ class TestAccountService:
# Verify integration was updated
from extensions.ext_database import db
from models.account import AccountIntegrate
from models import AccountIntegrate
integration = (
db.session.query(AccountIntegrate).filter_by(account_id=account.id, provider="exists-google").first()
@@ -2303,7 +2303,7 @@ class TestRegisterService:
# Verify account was created
from extensions.ext_database import db
from models.account import Account
from models import Account
from models.model import DifySetup
account = db.session.query(Account).filter_by(email=admin_email).first()
@@ -2352,7 +2352,7 @@ class TestRegisterService:
# Verify no entities were created (rollback worked)
from extensions.ext_database import db
from models.account import Account, Tenant, TenantAccountJoin
from models import Account, Tenant, TenantAccountJoin
from models.model import DifySetup
account = db.session.query(Account).filter_by(email=admin_email).first()
@@ -2446,7 +2446,7 @@ class TestRegisterService:
# Verify OAuth integration was created
from extensions.ext_database import db
from models.account import AccountIntegrate
from models import AccountIntegrate
integration = db.session.query(AccountIntegrate).filter_by(account_id=account.id, provider=provider).first()
assert integration is not None
@@ -2472,7 +2472,7 @@ class TestRegisterService:
mock_external_service_dependencies["billing_service"].is_email_in_freeze.return_value = False
# Execute registration with pending status
from models.account import AccountStatus
from models import AccountStatus
account = RegisterService.register(
email=email,
@@ -2661,7 +2661,7 @@ class TestRegisterService:
# Verify new account was created with pending status
from extensions.ext_database import db
from models.account import Account, TenantAccountJoin
from models import Account, TenantAccountJoin
new_account = db.session.query(Account).filter_by(email=new_member_email).first()
assert new_account is not None

View File

@@ -5,7 +5,7 @@ import pytest
from faker import Faker
from core.plugin.impl.exc import PluginDaemonClientSideError
from models.account import Account
from models import Account
from models.model import AppModelConfig, Conversation, EndUser, Message, MessageAgentThought
from services.account_service import AccountService, TenantService
from services.agent_service import AgentService

View File

@@ -4,7 +4,7 @@ import pytest
from faker import Faker
from werkzeug.exceptions import NotFound
from models.account import Account
from models import Account
from models.model import MessageAnnotation
from services.annotation_service import AppAnnotationService
from services.app_service import AppService

View File

@@ -4,7 +4,7 @@ import pytest
from faker import Faker
from constants.model_template import default_app_templates
from models.account import Account
from models import Account
from models.model import App, Site
from services.account_service import AccountService, TenantService
from services.app_service import AppService

View File

@@ -8,7 +8,7 @@ from sqlalchemy import Engine
from werkzeug.exceptions import NotFound
from configs import dify_config
from models.account import Account, Tenant
from models import Account, Tenant
from models.enums import CreatorUserRole
from models.model import EndUser, UploadFile
from services.errors.file import FileTooLargeError, UnsupportedFileTypeError

View File

@@ -4,7 +4,7 @@ import pytest
from faker import Faker
from core.rag.index_processor.constant.built_in_field import BuiltInField
from models.account import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models.dataset import Dataset, DatasetMetadata, DatasetMetadataBinding, Document
from services.entities.knowledge_entities.knowledge_entities import MetadataArgs
from services.metadata_service import MetadataService
@@ -17,9 +17,7 @@ class TestMetadataService:
def mock_external_service_dependencies(self):
"""Mock setup for external service dependencies."""
with (
patch(
"services.metadata_service.current_user", create_autospec(Account, instance=True)
) as mock_current_user,
patch("libs.login.current_user", create_autospec(Account, instance=True)) as mock_current_user,
patch("services.metadata_service.redis_client") as mock_redis_client,
patch("services.dataset_service.DocumentService") as mock_document_service,
):

View File

@@ -5,7 +5,7 @@ from faker import Faker
from core.entities.model_entities import ModelStatus
from core.model_runtime.entities.model_entities import FetchFrom, ModelType
from models.account import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models.provider import Provider, ProviderModel, ProviderModelSetting, ProviderType
from services.model_provider_service import ModelProviderService

View File

@@ -5,7 +5,7 @@ from faker import Faker
from sqlalchemy import select
from werkzeug.exceptions import NotFound
from models.account import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models.dataset import Dataset
from models.model import App, Tag, TagBinding
from services.tag_service import TagService

View File

@@ -5,7 +5,7 @@ from faker import Faker
from sqlalchemy import select
from core.app.entities.app_invoke_entities import InvokeFrom
from models.account import Account
from models import Account
from models.model import Conversation, EndUser
from models.web import PinnedConversation
from services.account_service import AccountService, TenantService

View File

@@ -7,7 +7,7 @@ from faker import Faker
from werkzeug.exceptions import NotFound, Unauthorized
from libs.password import hash_password
from models.account import Account, AccountStatus, Tenant, TenantAccountJoin, TenantAccountRole
from models import Account, AccountStatus, Tenant, TenantAccountJoin, TenantAccountRole
from models.model import App, Site
from services.errors.account import AccountLoginError, AccountNotFoundError, AccountPasswordError
from services.webapp_auth_service import WebAppAuthService, WebAppAuthType

View File

@@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from faker import Faker
from models.account import Account, Tenant, TenantAccountJoin, TenantAccountRole
from models import Account, Tenant, TenantAccountJoin, TenantAccountRole
from services.workspace_service import WorkspaceService

View File

@@ -3,7 +3,7 @@ from unittest.mock import patch
import pytest
from faker import Faker
from models.account import Account, Tenant
from models import Account, Tenant
from models.tools import ApiToolProvider
from services.tools.api_tools_manage_service import ApiToolManageService

View File

@@ -4,7 +4,7 @@ import pytest
from faker import Faker
from core.tools.entities.tool_entities import ToolProviderType
from models.account import Account, Tenant
from models import Account, Tenant
from models.tools import MCPToolProvider
from services.tools.mcp_tools_manage_service import UNCHANGED_SERVER_URL_PLACEHOLDER, MCPToolManageService

View File

@@ -15,7 +15,7 @@ from core.app.app_config.entities import (
)
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 import Account, Tenant
from models.api_based_extension import APIBasedExtension
from models.model import App, AppMode, AppModelConfig
from models.workflow import Workflow