MCPcopy Create free account
hub / github.com/MemTensor/MemOS / mem_cube

Function mem_cube

tests/mem_cube/test_general.py:17–50  ·  view source on GitHub ↗

Set up test fixtures for GeneralMemCube.

()

Source from the content-addressed store, hash-verified

15
16@pytest.fixture
17def mem_cube():
18 """Set up test fixtures for GeneralMemCube."""
19 with open("./examples/data/mem_cube_2/config.json", encoding="utf-8") as f:
20 config_data = json.load(f)
21 mock_config = GeneralMemCubeConfig.model_validate(config_data)
22
23 # Create mock instances that are also instances of the base classes
24 mock_text_mem = MagicMock(spec=BaseTextMemory)
25 mock_act_mem = MagicMock(spec=BaseActMemory)
26 mock_para_mem = MagicMock(spec=BaseParaMemory)
27
28 # Mock the MemoryFactory.from_config method to return our mock instances
29 def mock_from_config(config_factory):
30 backend = config_factory.backend
31 if backend == "general_text":
32 return mock_text_mem
33 elif backend == "kv_cache":
34 return mock_act_mem
35 elif backend == "lora":
36 return mock_para_mem
37 else:
38 # Fallback for any other backend
39 return MagicMock()
40
41 with patch("memos.memories.factory.MemoryFactory.from_config", side_effect=mock_from_config):
42 # Create the GeneralMemCube instance
43 mem_cube = GeneralMemCube(mock_config)
44
45 # Attach the mock instances for easy access in tests
46 mem_cube.text_mem = mock_text_mem
47 mem_cube.act_mem = mock_act_mem
48 mem_cube.para_mem = mock_para_mem
49
50 return mem_cube
51
52
53def test_load_with_real_directory():

Callers

nothing calls this directly

Calls 4

GeneralMemCubeClass · 0.90
patchFunction · 0.85
openFunction · 0.50
loadMethod · 0.45

Tested by

no test coverage detected