mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
fix: resolve ruff PT012 and pyrefly type errors in tests
This commit is contained in:
parent
4d251883ab
commit
fc2e19a9a7
@ -1,4 +1,5 @@
|
||||
import uuid
|
||||
from typing import Literal
|
||||
from unittest.mock import ANY, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
@ -132,7 +133,10 @@ class TestAppGenerateService:
|
||||
}
|
||||
|
||||
def _create_test_app_and_account(
|
||||
self, db_session_with_containers: Session, mock_external_service_dependencies, mode="chat"
|
||||
self,
|
||||
db_session_with_containers: Session,
|
||||
mock_external_service_dependencies,
|
||||
mode: Literal["chat", "agent-chat", "advanced-chat", "workflow", "completion"] = "chat",
|
||||
):
|
||||
"""
|
||||
Helper method to create a test app and account for testing.
|
||||
|
||||
@ -1072,24 +1072,20 @@ class TestAppService:
|
||||
password=generate_valid_password(fake),
|
||||
)
|
||||
TenantService.create_owner_tenant_if_not_exist(account, name=fake.company())
|
||||
tenant = account.current_tenant
|
||||
|
||||
# Import here to avoid circular dependency
|
||||
from services.app_service import AppService, CreateAppParams
|
||||
|
||||
app_service = AppService()
|
||||
from services.app_service import CreateAppParams
|
||||
|
||||
# Attempt to create app with invalid mode - Pydantic will reject invalid literal
|
||||
with pytest.raises(ValidationError):
|
||||
app_args = CreateAppParams(
|
||||
CreateAppParams(
|
||||
name=fake.company(),
|
||||
description=fake.text(max_nb_chars=100),
|
||||
mode="invalid_mode",
|
||||
mode="invalid_mode", # type: ignore[arg-type]
|
||||
icon_type="emoji",
|
||||
icon="❌",
|
||||
icon_background="#D63031",
|
||||
)
|
||||
app_service.create_app(tenant.id, app_args, account)
|
||||
|
||||
def test_get_apps_with_special_characters_in_name(
|
||||
self, db_session_with_containers: Session, mock_external_service_dependencies
|
||||
|
||||
Loading…
Reference in New Issue
Block a user