Files
zkxw/backend/tests/test_effective_role_user_lookup.py
T
zlwuandCursor de22678c87 feat: ship OA drafts/badges, role dual-track, and test-env deploy tooling.
Add approval instance drafts with menu badges, dual-track user/role read model and role bound names, form-designer outline docs, and bare-metal test deploy scripts. Ignore local test-server credential file.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 13:58:47 +08:00

32 lines
1.2 KiB
Python

"""按有效角色查用户:空入参行为(不依赖 DB)。"""
from app.services.web_auth_roles import (
list_user_ids_with_any_effective_role_ids,
list_user_ids_with_effective_role_name,
)
class _DummySession:
def query(self, *args, **kwargs): # pragma: no cover
raise AssertionError("空入参不应访问数据库")
def test_list_by_role_name_empty_inputs():
db = _DummySession()
assert list_user_ids_with_effective_role_name(db, tenant_no="", role_name="实验专员") == set()
assert list_user_ids_with_effective_role_name(db, tenant_no="zkxw", role_name="") == set()
assert list_user_ids_with_effective_role_name(
db, tenant_no="zkxw", role_name="实验专员", candidate_user_ids=[]
) == set()
def test_list_by_role_ids_empty_inputs():
db = _DummySession()
assert list_user_ids_with_any_effective_role_ids(db, tenant_no="zkxw", role_ids=[]) == []
assert list_user_ids_with_any_effective_role_ids(db, tenant_no="", role_ids=["r1"]) == []
assert (
list_user_ids_with_any_effective_role_ids(
db, tenant_no="zkxw", role_ids=["r1"], candidate_user_ids=[]
)
== []
)