mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
test(api): use the str enums instead of raw strings in three test modules (#45102)
Co-authored-by: Felix Shi <204130665+shi-felix@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
4 files changed
+7
-6
No files matched your search
@@ -12,6 +12,7 @@ import services.installed_app_generation_service as completion_service_module
|
||||
from core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededError
|
||||
from graphon.model_runtime.errors.invoke import InvokeError
|
||||
from models import App, AppMode, Conversation, InstalledApp, Tenant
|
||||
from models.enums import ConversationFromSource
|
||||
from repositories.installed_app_repository import SQLAlchemyInstalledAppRepository
|
||||
from services.account_errors import AccountNotFoundError
|
||||
from services.app_generate_service import AppGenerateService
|
||||
@@ -815,7 +816,9 @@ class TestCompletionCases:
|
||||
id=conversation_id,
|
||||
app_id=str(uuid4()) if rejection == "other_app" else harness.target_app.id,
|
||||
from_account_id=str(uuid4()) if rejection == "other_account" else harness.account.id,
|
||||
from_source="api" if rejection == "api" else "console",
|
||||
from_source=ConversationFromSource.API
|
||||
if rejection == "api"
|
||||
else ConversationFromSource.CONSOLE,
|
||||
mode=AppMode.CHAT,
|
||||
name="Existing conversation",
|
||||
_inputs={},
|
||||
|
||||
@@ -10,6 +10,7 @@ from models.agent import (
|
||||
AgentWorkspaceBinding,
|
||||
AgentWorkspaceOwnerType,
|
||||
)
|
||||
from models.enums import ConversationFromSource
|
||||
from models.model import App, AppMode, Conversation
|
||||
from services.agent.workspace_service import AgentWorkspaceNotFoundError, AgentWorkspaceService
|
||||
|
||||
@@ -81,7 +82,7 @@ def _persist_conversation(session: Session, *, binding_id: str | None = None) ->
|
||||
introduction="",
|
||||
system_instruction="",
|
||||
invoke_from=None,
|
||||
from_source="api",
|
||||
from_source=ConversationFromSource.API,
|
||||
from_end_user_id="user-1",
|
||||
from_account_id=None,
|
||||
read_at=None,
|
||||
|
||||
@@ -50,7 +50,6 @@ project-excludes = [
|
||||
"controllers/console/datasets/test_hit_testing.py",
|
||||
"controllers/console/datasets/test_hit_testing_base.py",
|
||||
"controllers/console/datasets/test_metadata.py",
|
||||
"controllers/console/explore/test_completion.py",
|
||||
"controllers/console/snippets/test_snippet_workflow.py",
|
||||
"controllers/console/snippets/test_snippet_workflow_draft_variable.py",
|
||||
"controllers/console/tag/test_tags.py",
|
||||
@@ -124,7 +123,6 @@ project-excludes = [
|
||||
"core/app/apps/agent_app/test_app_generator.py",
|
||||
"core/app/apps/agent_app/test_app_runner.py",
|
||||
"core/app/apps/agent_app/test_runtime_request_builder.py",
|
||||
"core/app/apps/agent_app/test_session_store.py",
|
||||
"core/app/apps/agent_chat/test_app_config_manager.py",
|
||||
"core/app/apps/agent_chat/test_generate_response_converter.py",
|
||||
"core/app/apps/chat/test_app_config_manager.py",
|
||||
@@ -388,7 +386,6 @@ project-excludes = [
|
||||
"services/test_billing_service.py",
|
||||
"services/test_clear_free_plan_tenant_expired_logs.py",
|
||||
"services/test_conversation_service.py",
|
||||
"services/test_credit_pool_service.py",
|
||||
"services/knowledge/test_dataset_service.py",
|
||||
"services/data_source/test_provider_service.py",
|
||||
"services/knowledge/external/test_service.py",
|
||||
|
||||
@@ -574,7 +574,7 @@ def test_deduct_credits_capped_uses_billing_consume_capped_when_enabled(
|
||||
],
|
||||
)
|
||||
def test_non_positive_credit_request_skips_tenant_redis_lock(
|
||||
deduct_method,
|
||||
deduct_method: Callable[..., int],
|
||||
sqlite_session: Session,
|
||||
) -> None:
|
||||
with patch("services.credit_pool_service.redis_client.lock") as lock:
|
||||
|
||||
Reference in new issue
Block a user