feat(system):优化后端
1.新增后端测试 2.增加了后端的加密 3.增加了i18n(国际化)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""``ray_hook`` 中纯逻辑容器与 actor 句柄缓存的行为。"""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from kilostar.utils.ray_hook import ActorList
|
||||
|
||||
|
||||
def test_actor_list_attribute_set_get_delete():
|
||||
actors = ActorList()
|
||||
actors.foo = "bar"
|
||||
assert actors.foo == "bar"
|
||||
del actors.foo
|
||||
with pytest.raises(AttributeError):
|
||||
_ = actors.foo
|
||||
|
||||
|
||||
def test_actor_list_missing_raises_attribute_error():
|
||||
actors = ActorList()
|
||||
with pytest.raises(AttributeError):
|
||||
_ = actors.not_exist
|
||||
|
||||
|
||||
def test_actor_list_delete_missing_raises_attribute_error():
|
||||
actors = ActorList()
|
||||
with pytest.raises(AttributeError):
|
||||
del actors.not_exist
|
||||
|
||||
|
||||
def test_ray_actor_hook_uses_fake_registry(fake_actors):
|
||||
"""``ray_actor_hook`` 通过 fake registry 取 actor 并组装成 ActorList。"""
|
||||
handle = MagicMock()
|
||||
fake_actors.register("postgres_database", handle)
|
||||
|
||||
from kilostar.utils.ray_hook import ray_actor_hook
|
||||
|
||||
actors = ray_actor_hook("postgres_database")
|
||||
assert actors.postgres_database is handle
|
||||
|
||||
|
||||
def test_ray_actor_hook_unknown_actor_raises(fake_actors):
|
||||
from kilostar.utils.ray_hook import ray_actor_hook
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
ray_actor_hook("does_not_exist")
|
||||
Reference in New Issue
Block a user