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
chore: migrate account role test to testcontainers (#38010)
Escape0707eb4ec93cea08
diff --git a/api/tests/test_containers_integration_tests/.ruff.toml b/api/tests/test_containers_integration_tests/.ruff.tomlindex 68e3f9af4bd..54bc58a79ad 100644--- a/api/tests/test_containers_integration_tests/.ruff.toml+++ b/api/tests/test_containers_integration_tests/.ruff.toml@@ -27,7 +27,6 @@ extend-select = ["ANN401", "ARG", "TID251"]"controllers/web/test_wraps.py" = ["ARG"]"core/app/layers/test_pause_state_persist_layer.py" = ["ARG"]"core/rag/retrieval/test_dataset_retrieval_integration.py" = ["ARG"]-"models/test_account.py" = ["ARG"]"models/test_conversation_message_inputs.py" = ["ARG"]"models/test_conversation_status_count.py" = ["ARG"]"repositories/test_sqlalchemy_api_workflow_run_repository.py" = ["ARG"]diff --git a/api/tests/test_containers_integration_tests/models/test_account.py b/api/tests/test_containers_integration_tests/models/test_account.pyindex 6fd6716cbb9..22388694bc9 100644--- a/api/tests/test_containers_integration_tests/models/test_account.py+++ b/api/tests/test_containers_integration_tests/models/test_account.py@@ -3,6 +3,7 @@ Integration tests for Account and Tenant model methods that interact with the daMigrated from unit_tests/models/test_account_models.py, replacing@patch("models.account.db") mock patches with real PostgreSQL operations.+Also absorbs unit_tests/models/test_account.py role helper coverage.Covers:- Account.current_tenant setter (sets _current_tenant and role from TenantAccountJoin)@@ -12,6 +13,7 @@ Covers:"""from collections.abc import Generator+from typing import castfrom uuid import uuid4import pytest@@ -20,8 +22,10 @@ from sqlalchemy.orm import Sessionfrom models.account import Account, AccountIntegrate, Tenant, TenantAccountJoin, TenantAccountRole+TrackedRow = Account | AccountIntegrate | Tenant | TenantAccountJoin-def _cleanup_tracked_rows(db_session: Session, tracked: list) -> None:++def _cleanup_tracked_rows(db_session: Session, tracked: list[TrackedRow]) -> None:"""Delete rows tracked during the test so committed state does not leak into the DB.Rolls back any pending (uncommitted) session state first, then issues DELETE@@ -52,7 +56,7 @@ def _build_account(email_prefix: str = "account") -> Account:class _DBTrackingTestBase:"""Base class providing a tracker list and shared row factories for account/tenant tests."""- _tracked: list+ _tracked: list[TrackedRow]@pytest.fixture(autouse=True)def _setup_cleanup(self, db_session_with_containers: Session) -> Generator[None, None, None]:@@ -84,6 +88,22 @@ class _DBTrackingTestBase:return join+class TestTenantAccountRole:+ """Tests for TenantAccountRole helper methods."""++ def test_account_is_privileged_role(self) -> None:+ assert TenantAccountRole.ADMIN == "admin"+ assert TenantAccountRole.OWNER == "owner"+ assert TenantAccountRole.EDITOR == "editor"+ assert TenantAccountRole.NORMAL == "normal"++ assert TenantAccountRole.is_privileged_role(TenantAccountRole.ADMIN)+ assert TenantAccountRole.is_privileged_role(TenantAccountRole.OWNER)+ assert not TenantAccountRole.is_privileged_role(TenantAccountRole.NORMAL)+ assert not TenantAccountRole.is_privileged_role(TenantAccountRole.EDITOR)+ assert not TenantAccountRole.is_privileged_role(cast(TenantAccountRole, ""))++class TestAccountCurrentTenantSetter(_DBTrackingTestBase):"""Integration tests for Account.current_tenant property setter."""@@ -176,7 +196,7 @@ class TestAccountGetByOpenId(_DBTrackingTestBase):assert result is not Noneassert result.id == account.id- def test_get_by_openid_returns_none_when_no_integrate_exists(self, db_session_with_containers: Session) -> None:+ def test_get_by_openid_returns_none_when_no_integrate_exists(self) -> None:"""get_by_openid returns None when no AccountIntegrate row matches."""result = Account.get_by_openid("github", f"github_{uuid4()}")diff --git a/api/tests/test_containers_integration_tests/pyrefly.toml b/api/tests/test_containers_integration_tests/pyrefly.tomlindex 92c84320d9a..b9e83741d05 100644--- a/api/tests/test_containers_integration_tests/pyrefly.toml+++ b/api/tests/test_containers_integration_tests/pyrefly.toml@@ -50,7 +50,6 @@ project-excludes = ["libs/broadcast_channel/redis/test_streams_channel.py","libs/test_auto_renew_redis_lock_integration.py","libs/test_rate_limiter_integration.py",- "models/test_account.py","models/test_conversation_message_inputs.py","models/test_types_enum_text.py","repositories/test_sqlalchemy_api_workflow_node_execution_repository.py",diff --git a/api/tests/unit_tests/models/test_account.py b/api/tests/unit_tests/models/test_account.pydeleted file mode 100644index f555fc58d79..00000000000--- a/api/tests/unit_tests/models/test_account.py+++ /dev/null@@ -1,14 +0,0 @@-from models.account import TenantAccountRole---def test_account_is_privileged_role():- assert TenantAccountRole.ADMIN == "admin"- assert TenantAccountRole.OWNER == "owner"- assert TenantAccountRole.EDITOR == "editor"- assert TenantAccountRole.NORMAL == "normal"-- assert TenantAccountRole.is_privileged_role(TenantAccountRole.ADMIN)- assert TenantAccountRole.is_privileged_role(TenantAccountRole.OWNER)- assert not TenantAccountRole.is_privileged_role(TenantAccountRole.NORMAL)- assert not TenantAccountRole.is_privileged_role(TenantAccountRole.EDITOR)- assert not TenantAccountRole.is_privileged_role("")