Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
test: move API token service coverage to unit tests (#38918)
Asuka Minatof6db23444db6
diff --git a/api/tests/test_containers_integration_tests/services/test_api_token_service.py b/api/tests/unit_tests/services/test_api_token_service.pysimilarity index 95%rename from api/tests/test_containers_integration_tests/services/test_api_token_service.pyrename to api/tests/unit_tests/services/test_api_token_service.pyindex 9d0082a421d..b3e5af87087 100644--- a/api/tests/test_containers_integration_tests/services/test_api_token_service.py+++ b/api/tests/unit_tests/services/test_api_token_service.py@@ -1,22 +1,38 @@+"""Unit tests for API token caching and SQLite-backed token lookup."""+from __future__ import annotations+from collections.abc import Iteratorfrom datetime import datetimefrom unittest.mock import MagicMock, patchfrom uuid import uuid4import pytestfrom flask import Flask+from sqlalchemy.orm import Sessionfrom werkzeug.exceptions import Unauthorizedimport services.api_token_service as api_token_service_module+from models.engine import dbfrom models.model import ApiTokenfrom services.api_token_service import ApiTokenCache, CachedApiToken+def api_token_db() -> Iterator[Session]:+ """Provide the production database extension with an isolated SQLite token table."""+ app = Flask(__name__)+ app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"+ db.init_app(app)++ with app.app_context():+ ApiToken.__table__.create(db.engine)+ with Session(db.engine, expire_on_commit=False) as session:+ yield session++class TestQueryTokenFromDb:- def test_should_return_api_token_and_cache_when_token_exists(- self, flask_app_with_containers: Flask, db_session_with_containers- ):+ def test_should_return_api_token_and_cache_when_token_exists(self, api_token_db: Session) -> None:tenant_id = str(uuid4())app_id = str(uuid4())token_value = f"app-test-{uuid4()}"@@ -27,8 +43,8 @@ class TestQueryTokenFromDb:api_token.tenant_id = tenant_idapi_token.type = "app"api_token.token = token_value- db_session_with_containers.add(api_token)- db_session_with_containers.commit()+ api_token_db.add(api_token)+ api_token_db.commit()with (patch.object(api_token_service_module.ApiTokenCache, "set") as mock_cache_set,@@ -41,9 +57,7 @@ class TestQueryTokenFromDb:mock_cache_set.assert_called_once()mock_record_usage.assert_called_once_with(token_value, "app")- def test_should_cache_null_and_raise_unauthorized_when_token_not_found(- self, flask_app_with_containers: Flask, db_session_with_containers- ):+ def test_should_cache_null_and_raise_unauthorized_when_token_not_found(self, api_token_db: Session) -> None:with (patch.object(api_token_service_module.ApiTokenCache, "set") as mock_cache_set,patch.object(api_token_service_module, "record_token_usage") as mock_record_usage,