diff --git a/api/services/app_service.py b/api/services/app_service.py index ec8c717fae..6716833f6c 100644 --- a/api/services/app_service.py +++ b/api/services/app_service.py @@ -50,6 +50,7 @@ class CreateAppParams(BaseModel): icon_background: str | None = None api_rph: int = 0 api_rpm: int = 0 + max_active_requests: int | None = None class AppService: @@ -172,6 +173,7 @@ class AppService: app.tenant_id = tenant_id app.api_rph = params.api_rph app.api_rpm = params.api_rpm + app.max_active_requests = params.max_active_requests app.created_by = account.id app.updated_by = account.id 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 d74d68fc83..ce5e59a762 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 @@ -164,6 +164,8 @@ class TestAppGenerateService: TenantService.create_owner_tenant_if_not_exist(account, name=fake.company()) tenant = account.current_tenant + from services.app_service import AppService, CreateAppParams + # Create app with realistic data app_args = CreateAppParams( name=fake.company(), @@ -177,8 +179,6 @@ class TestAppGenerateService: max_active_requests=5, ) - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) 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 1d3128527f..e897ff3557 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 @@ -2,6 +2,7 @@ from unittest.mock import create_autospec, patch import pytest from faker import Faker +from pydantic import ValidationError from sqlalchemy.orm import Session from constants.model_template import default_app_templates @@ -670,6 +671,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -678,10 +682,6 @@ class TestAppService: icon="๐ŸŒ", icon_background="#74B9FF", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -730,6 +730,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -738,10 +741,6 @@ class TestAppService: icon="๐Ÿ”Œ", icon_background="#A29BFE", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -790,6 +789,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -798,10 +800,6 @@ class TestAppService: icon="๐Ÿ”„", icon_background="#FD79A8", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -841,6 +839,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -849,10 +850,6 @@ class TestAppService: icon="๐Ÿ—‘๏ธ", icon_background="#E17055", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -893,6 +890,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -901,10 +901,6 @@ class TestAppService: icon="๐Ÿงน", icon_background="#00B894", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -953,6 +949,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -961,10 +960,6 @@ class TestAppService: icon="๐Ÿ“Š", icon_background="#6C5CE7", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -992,6 +987,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -1000,10 +998,6 @@ class TestAppService: icon="๐Ÿ”—", icon_background="#FDCB6E", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -1032,6 +1026,9 @@ class TestAppService: tenant = account.current_tenant # Create app first + # Import here to avoid circular dependency + from services.app_service import AppService, CreateAppParams + app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100), @@ -1040,10 +1037,6 @@ class TestAppService: icon="๐Ÿ†”", icon_background="#E84393", ) - - # Import here to avoid circular dependency - from services.app_service import AppService, CreateAppParams - app_service = AppService() app = app_service.create_app(tenant.id, app_args, account) @@ -1087,7 +1080,7 @@ class TestAppService: app_service = AppService() # Attempt to create app with invalid mode - Pydantic will reject invalid literal - with pytest.raises(Exception): + with pytest.raises(ValidationError): app_args = CreateAppParams( name=fake.company(), description=fake.text(max_nb_chars=100),