fix: #36585 dep inject current user id (#36845)

Co-authored-by: duongynhi000005-oss <duongynhi000005-oss@users.noreply.github.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-05-31 14:37:39 +00:00
1 parent c6474a2a8b
commit f241ae25be
2 files changed
+61

No files matched your search

@@ -22,6 +22,7 @@ from controllers.console.wraps import (
setup_required,
with_current_tenant_id,
with_current_user,
with_current_user_id,
)
from models import Account
from models.account import AccountStatus, TenantAccountRole
@@ -124,6 +125,19 @@ class TestCurrentContextInjection:
with patch("controllers.console.wraps.current_account_with_tenant", return_value=(current_user, "tenant-123")):
assert Handler().get() is current_user
def test_with_current_user_id_injects_user_id_string(self):
current_user = make_account("user-42")
class Handler:
@with_current_user_id
def get(self, current_user_id: str):
return current_user_id
with patch("controllers.console.wraps.current_account_with_tenant", return_value=(current_user, "tenant-123")):
result = Handler().get()
assert result == "user-42"
assert isinstance(result, str)
def test_stacked_current_context_injectors_preserve_argument_order(self):
current_user = make_account()
@@ -136,6 +150,18 @@ class TestCurrentContextInjection:
with patch("controllers.console.wraps.current_account_with_tenant", return_value=(current_user, "tenant-123")):
assert Handler().get() == ("tenant-123", current_user)
def test_stacked_user_id_and_tenant_id_injectors(self):
current_user = make_account("user-99")
class Handler:
@with_current_user_id
@with_current_tenant_id
def get(self, current_tenant_id: str, current_user_id: str):
return current_user_id, current_tenant_id
with patch("controllers.console.wraps.current_account_with_tenant", return_value=(current_user, "tenant-456")):
assert Handler().get() == ("user-99", "tenant-456")
class TestModelValidationInjection:
"""Test request model validation decorator."""