revert: revert human input relevant code (#31766)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
QuantumGhost
2026-01-30 19:18:49 +08:00
committed by GitHub
parent ba568a634d
commit 90fe9abab7
470 changed files with 2082 additions and 32508 deletions

View File

@ -1,4 +1,3 @@
import logging
import os
import pathlib
import random
@ -11,34 +10,26 @@ from flask.testing import FlaskClient
from sqlalchemy.orm import Session
from app_factory import create_app
from configs.app_config import DifyConfig
from extensions.ext_database import db
from models import Account, DifySetup, Tenant, TenantAccountJoin
from services.account_service import AccountService, RegisterService
_DEFUALT_TEST_ENV = ".env"
_DEFAULT_VDB_TEST_ENV = "vdb.env"
_logger = logging.getLogger(__name__)
# Loading the .env file if it exists
def _load_env():
current_file_path = pathlib.Path(__file__).absolute()
# Items later in the list have higher precedence.
env_file_paths = [
os.getenv("DIFY_TEST_ENV_FILE", str(current_file_path.parent / _DEFUALT_TEST_ENV)),
os.getenv("DIFY_VDB_TEST_ENV_FILE", str(current_file_path.parent / _DEFAULT_VDB_TEST_ENV)),
]
files_to_load = [".env", "vdb.env"]
for env_path_str in env_file_paths:
if not pathlib.Path(env_path_str).exists():
_logger.warning("specified configuration file %s not exist", env_path_str)
env_file_paths = [current_file_path.parent / i for i in files_to_load]
for path in env_file_paths:
if not path.exists():
continue
from dotenv import load_dotenv
# Set `override=True` to ensure values from `vdb.env` take priority over values from `.env`
load_dotenv(str(env_path_str), override=True)
load_dotenv(str(path), override=True)
_load_env()
@ -50,12 +41,6 @@ os.environ.setdefault("OPENDAL_SCHEME", "fs")
_CACHED_APP = create_app()
@pytest.fixture(scope="session")
def dify_config() -> DifyConfig:
config = DifyConfig() # type: ignore
return config
@pytest.fixture
def flask_app() -> Flask:
return _CACHED_APP