-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_e2e.py
More file actions
78 lines (59 loc) · 2.48 KB
/
Copy pathtest_e2e.py
File metadata and controls
78 lines (59 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""End-to-end tests for APC CLI.
These tests require a running backend. Set RUN_E2E_TESTS=true to enable.
"""
import json
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
from appliers.manifest import ToolManifest
class TestMemoryViaLLM(unittest.TestCase):
"""Test that memory sync via LLM writes files correctly."""
def test_llm_memory_sync_writes_claude_md(self):
from appliers.claude import ClaudeApplier
tmpdir = tempfile.mkdtemp()
claude_dir = Path(tmpdir) / ".claude"
claude_dir.mkdir()
claude_md = claude_dir / "CLAUDE.md"
manifest = ToolManifest("claude-code", path=Path(tmpdir) / "manifest.json")
collected = [
{
"id": "abc123",
"source_tool": "openclaw",
"source_file": "USER.md",
"content": "Prefers TypeScript\nUses 2-space indentation",
},
]
llm_response = json.dumps(
[
{
"file_path": str(claude_md),
"content": "## Preferences\n- Prefers TypeScript\n- Uses 2-space indentation\n",
}
]
)
with (
patch("appliers.claude._claude_md", return_value=claude_md),
patch("appliers.claude._claude_dir", return_value=claude_dir),
patch("appliers.base.call_llm", return_value=llm_response, create=True),
patch("llm_client.call_llm", return_value=llm_response),
):
applier = ClaudeApplier()
count = applier.apply_memory_via_llm(collected, manifest)
self.assertEqual(count, 1)
content = claude_md.read_text()
self.assertIn("Prefers TypeScript", content)
self.assertIn("Uses 2-space indentation", content)
def test_no_llm_configured_shows_warning(self):
from appliers.claude import ClaudeApplier
tmpdir = tempfile.mkdtemp()
manifest = ToolManifest("claude-code", path=Path(tmpdir) / "manifest.json")
collected = [{"id": "abc", "source_tool": "test", "content": "test"}]
# Simulate LLM not configured
from llm_client import LLMError
with patch("llm_client.call_llm", side_effect=LLMError("No LLM model configured")):
applier = ClaudeApplier()
count = applier.apply_memory_via_llm(collected, manifest)
self.assertEqual(count, -1) # -1 signals LLM failure
if __name__ == "__main__":
unittest.main()