mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 22:30:31 +08:00
Refact: Tenant api (#14288)
### What problem does this PR solve? Refact: Tenant api ### Type of change - [x] Refactoring
This commit is contained in:
@@ -180,7 +180,7 @@ def _load_tenant_module(monkeypatch):
|
||||
common_pkg.settings = settings_mod
|
||||
|
||||
sys.modules.pop("test_tenant_app_unit_module", None)
|
||||
module_path = repo_root / "api" / "apps" / "tenant_app.py"
|
||||
module_path = repo_root / "api" / "apps" / "restful_apis" / "tenant_api.py"
|
||||
spec = importlib.util.spec_from_file_location("test_tenant_app_unit_module", module_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
module.manager = _DummyManager()
|
||||
@@ -268,20 +268,21 @@ def test_rm_and_tenant_list_matrix_unit(monkeypatch):
|
||||
module = _load_tenant_module(monkeypatch)
|
||||
|
||||
module.current_user.id = "outsider"
|
||||
res = module.rm("tenant-1", "user-2")
|
||||
_set_request_json(monkeypatch, module, {"user_id": "user-2"})
|
||||
res = _run(module.rm("tenant-1"))
|
||||
assert res["code"] == module.RetCode.AUTHENTICATION_ERROR, res
|
||||
assert res["message"] == "No authorization.", res
|
||||
|
||||
module.current_user.id = "tenant-1"
|
||||
deleted = []
|
||||
monkeypatch.setattr(module.UserTenantService, "filter_delete", lambda conditions: deleted.append(conditions) or True)
|
||||
res = module.rm("tenant-1", "user-2")
|
||||
res = _run(module.rm("tenant-1"))
|
||||
assert res["code"] == 0, res
|
||||
assert res["data"] is True, res
|
||||
assert deleted, "filter_delete should be called"
|
||||
|
||||
monkeypatch.setattr(module.UserTenantService, "filter_delete", lambda _conditions: (_ for _ in ()).throw(RuntimeError("rm boom")))
|
||||
res = module.rm("tenant-1", "user-2")
|
||||
res = _run(module.rm("tenant-1"))
|
||||
assert res["code"] == 100, res
|
||||
assert "rm boom" in res["message"], res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user