3030
3131
3232class TestLongTermMemory :
33- """测试LongTermMemory类 """
33+ """Test LongTermMemory class """
3434
3535 @pytest .mark .asyncio
3636 async def test_long_term_memory_creation (self ):
37- """测试LongTermMemory基本创建 """
37+ """Test basic LongTermMemory creation """
3838 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
3939 long_term_memory = LongTermMemory (backend = "local" )
4040
@@ -56,10 +56,10 @@ async def test_long_term_memory_creation(self):
5656
5757 @pytest .mark .asyncio
5858 async def test_long_term_memory_with_custom_backend (self ):
59- """测试LongTermMemory使用自定义backend实例 """
59+ """Test LongTermMemory with custom backend instance """
6060 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
6161
62- # 创建模拟backend实例
62+ # Create mock backend instance
6363 mock_backend = Mock (spec = BaseLongTermMemoryBackend )
6464 mock_backend .index = "test_index"
6565
@@ -69,21 +69,21 @@ async def test_long_term_memory_with_custom_backend(self):
6969
7070 @pytest .mark .asyncio
7171 async def test_long_term_memory_with_invalid_backend (self ):
72- """测试LongTermMemory使用无效backend类型 """
72+ """Test LongTermMemory with invalid backend type """
7373 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
7474
75- # 测试无效backend类型
75+ # Test invalid backend type
7676 with pytest .raises (ValueError ):
7777 LongTermMemory (backend = "invalid_backend" )
7878
7979 @pytest .mark .asyncio
8080 async def test_long_term_memory_properties (self ):
81- """测试LongTermMemory属性 """
81+ """Test LongTermMemory properties """
8282 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
8383
8484 long_term_memory = LongTermMemory (backend = "local" )
8585
86- # 测试基本属性
86+ # Test basic properties
8787 assert hasattr (long_term_memory , "backend" )
8888
8989 @pytest .mark .asyncio
@@ -93,10 +93,10 @@ async def test_long_term_memory_properties(self):
9393 async def test_long_term_memory_without_embedding_api_key (
9494 self , mock_get_credential , mock_get_ark_token
9595 ):
96- """测试在没有embedding api key时初始化LongTermMemory """
97- # Mock get_ark_token函数来抛出ValueError异常,模拟无法获取ARK token的情况
96+ """Test LongTermMemory initialization without embedding API key """
97+ # Mock get_ark_token function to throw ValueError exception, simulating inability to get ARK token
9898 mock_get_ark_token .side_effect = ValueError ("Failed to get ARK api key" )
99- # Mock get_credential_from_vefaas_iam函数来抛出FileNotFoundError异常,模拟无法从IAM文件获取凭证的情况
99+ # Mock get_credential_from_vefaas_iam function to throw FileNotFoundError exception, simulating inability to get credentials from IAM file
100100 mock_get_credential .side_effect = FileNotFoundError (
101101 "Mocked VeFaaS IAM file not found"
102102 )
@@ -110,31 +110,31 @@ async def test_long_term_memory_without_embedding_api_key(
110110
111111 @pytest .mark .asyncio
112112 async def test_long_term_memory_backend_initialization (self ):
113- """测试LongTermMemory backend初始化过程 """
113+ """Test LongTermMemory backend initialization process """
114114 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
115115
116116 long_term_memory = LongTermMemory (backend = "local" )
117117
118- # 验证backend已正确初始化
118+ # Verify backend is correctly initialized
119119 assert long_term_memory ._backend is not None
120120 assert isinstance (long_term_memory ._backend , InMemoryLongTermMemoryBackend )
121121
122122 @pytest .mark .asyncio
123123 async def test_long_term_memory_string_representation (self ):
124- """测试LongTermMemory的字符串表示 """
124+ """Test LongTermMemory string representation """
125125 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
126126
127127 long_term_memory = LongTermMemory (backend = "local" )
128128
129- # 测试字符串表示
129+ # Test string representation
130130 str_repr = str (long_term_memory )
131- # 检查是否包含关键信息
131+ # Check if contains key information
132132 assert "backend" in str_repr
133133 assert "local" in str_repr
134134
135135 @pytest .mark .asyncio
136136 async def test_long_term_memory_with_app_name (self ):
137- """测试LongTermMemory使用app_name参数 """
137+ """Test LongTermMemory with app_name parameter """
138138 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
139139
140140 app_name = "test_app"
@@ -146,12 +146,12 @@ async def test_long_term_memory_with_app_name(self):
146146
147147 @pytest .mark .asyncio
148148 async def test_long_term_memory_tool_integration (self ):
149- """测试LongTermMemory与Agent工具的集成 """
149+ """Test LongTermMemory integration with Agent tools """
150150 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
151151
152152 long_term_memory = LongTermMemory (backend = "local" )
153153
154- # 创建多个Agent实例测试工具集成
154+ # Create multiple Agent instances to test tool integration
155155 agents = []
156156 for i in range (3 ):
157157 agent = Agent (
@@ -166,18 +166,18 @@ async def test_long_term_memory_tool_integration(self):
166166 )
167167 agents .append (agent )
168168
169- # 验证每个Agent都有正确的工具集成
169+ # Verify each Agent has correct tool integration
170170 for agent in agents :
171171 assert load_memory in agent .tools
172172 assert agent .long_term_memory == long_term_memory
173173
174174 @pytest .mark .asyncio
175175 async def test_long_term_memory_backend_types (self ):
176- """测试LongTermMemory支持的不同backend类型 """
176+ """Test different backend types supported by LongTermMemory """
177177 os .environ ["MODEL_EMBEDDING_API_KEY" ] = "mocked_api_key"
178178
179- # 测试支持的backend类型
180- supported_backends = ["local" ] # 目前只支持local
179+ # Test supported backend types
180+ supported_backends = ["local" ] # Currently only supports local
181181
182182 for backend_type in supported_backends :
183183 long_term_memory = LongTermMemory (backend = backend_type )
0 commit comments