From fc2e19a9a7a0c731e31dbd40882c76fdaee77518 Mon Sep 17 00:00:00 2001 From: satishkc7 Date: Fri, 8 May 2026 15:33:47 -0500 Subject: [PATCH] fix: resolve ruff PT012 and pyrefly type errors in tests --- .../services/test_app_generate_service.py | 6 +++++- .../services/test_app_service.py | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/tests/test_containers_integration_tests/services/test_app_generate_service.py b/api/tests/test_containers_integration_tests/services/test_app_generate_service.py index ce5e59a762..bda1bc6ca2 100644 --- a/api/tests/test_containers_integration_tests/services/test_app_generate_service.py +++ b/api/tests/test_containers_integration_tests/services/test_app_generate_service.py @@ -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. diff --git a/api/tests/test_containers_integration_tests/services/test_app_service.py b/api/tests/test_containers_integration_tests/services/test_app_service.py index e897ff3557..87e355a6df 100644 --- a/api/tests/test_containers_integration_tests/services/test_app_service.py +++ b/api/tests/test_containers_integration_tests/services/test_app_service.py @@ -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