aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_sessions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sessions.py')
-rw-r--r--tests/test_sessions.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index 8ad48db..1e10a48 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -25,8 +25,8 @@ class TempRoot(unittest.TestCase):
class TestReadSession(TempRoot):
def test_basic_conversation(self):
path = write_session(self.root, "-p", "11111111-1111-1111-1111-111111111111", [
- user("¿por qué falla?", at=ts(0)),
- assistant("Miro.", tools=[("Bash", {"command": "make test"})], at=ts(5)),
+ user("why does it fail?", at=ts(0)),
+ assistant("Looking.", tools=[("Bash", {"command": "make test"})], at=ts(5)),
])
rec = S.read_session(path)
@@ -37,37 +37,37 @@ class TestReadSession(TempRoot):
self.assertEqual(rec["b"], "main")
self.assertFalse(rec["e"])
self.assertFalse(rec["ai"])
- self.assertEqual(rec["t"], "¿por qué falla?")
+ self.assertEqual(rec["t"], "why does it fail?")
self.assertEqual([m["r"] for m in rec["c"]], ["u", "a", "t"])
self.assertEqual(rec["c"][2]["x"], "Bash: make test")
def test_claude_title_beats_the_first_message(self):
path = write_session(self.root, "-p", "22222222-0000-0000-0000-000000000000", [
- user("arreglá esto", at=ts(0)),
- ai_title("Primer intento"),
- ai_title("Título final"),
+ user("fix this", at=ts(0)),
+ ai_title("First attempt"),
+ ai_title("Final title"),
])
rec = S.read_session(path)
- self.assertEqual(rec["t"], "Título final")
+ self.assertEqual(rec["t"], "Final title")
self.assertTrue(rec["ai"])
def test_ignores_harness_noise(self):
path = write_session(self.root, "-p", "33333333-0000-0000-0000-000000000000", [
user("<command-name>/clear</command-name>", at=ts(0)),
- user("<system-reminder>ojo</system-reminder>", at=ts(1)),
- user("texto real <system-reminder>ojo</system-reminder>", at=ts(2)),
+ user("<system-reminder>note</system-reminder>", at=ts(1)),
+ user("real text <system-reminder>note</system-reminder>", at=ts(2)),
user("meta", at=ts(2), isMeta=True),
- user("de un subagente", at=ts(3), isSidechain=True),
- assistant("respuesta de subagente", at=ts(4), isSidechain=True),
+ user("from a subagent", at=ts(3), isSidechain=True),
+ assistant("subagent reply", at=ts(4), isSidechain=True),
])
rec = S.read_session(path)
self.assertEqual(rec["u"], 1)
self.assertEqual(rec["a"], 0)
- self.assertEqual(rec["c"][0]["x"], "texto real")
+ self.assertEqual(rec["c"][0]["x"], "real text")
def test_tolerates_a_line_cut_in_half(self):
path = write_session(self.root, "-p", "44444444-0000-0000-0000-000000000000", [
- user("primero", at=ts(0)),
+ user("first", at=ts(0)),
])
with open(path, "a", encoding="utf-8") as f:
f.write('{"type": "user", "message": {"content": [{"type": "te')
@@ -92,7 +92,7 @@ class TestReadSession(TempRoot):
def test_short_chat_is_not_claude_p(self):
path = write_session(self.root, "-p", "77777777-0000-0000-0000-000000000000", [
- user("hola", at=ts(0)),
+ user("hello", at=ts(0)),
])
self.assertFalse(S.read_session(path)["n"])
@@ -105,8 +105,8 @@ class TestToolSummary(unittest.TestCase):
def test_falls_back_to_first_string_for_unknown_tool(self):
self.assertEqual(
- S.tool_summary({"name": "Rara", "input": {"n": 1, "q": "algo"}}),
- "Rara: algo")
+ S.tool_summary({"name": "Odd", "input": {"n": 1, "q": "something"}}),
+ "Odd: something")
def test_truncates_long_arguments(self):
out = S.tool_summary({"name": "Bash", "input": {"command": "a" * 500}})
@@ -115,7 +115,7 @@ class TestToolSummary(unittest.TestCase):
def test_no_usable_arguments(self):
self.assertEqual(S.tool_summary({"name": "X", "input": {"n": 1}}), "X")
- self.assertEqual(S.tool_summary({"name": "X", "input": "no es dict"}), "X")
+ self.assertEqual(S.tool_summary({"name": "X", "input": "not a dict"}), "X")
class TestLoad(TempRoot):
@@ -126,7 +126,7 @@ class TestLoad(TempRoot):
def test_infers_the_path_from_another_session_of_the_project(self):
write_session(self.root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-000000000001",
- [user("con cwd", at=ts(0))])
+ [user("with cwd", at=ts(0))])
write_session(self.root, "-home-u-proj", "dddddddd-0000-0000-0000-000000000004",
[{"type": "system", "timestamp": ts(30)}])
orphan = next(s for s in self.load() if s["id"].startswith("dddddddd"))
@@ -134,18 +134,18 @@ class TestLoad(TempRoot):
self.assertTrue(orphan["i"])
def test_no_known_path_keeps_the_directory_name(self):
- write_session(self.root, "-sin-cwd", "eeeeeeee-0000-0000-0000-000000000005",
+ write_session(self.root, "-no-cwd", "eeeeeeee-0000-0000-0000-000000000005",
[{"type": "system", "timestamp": ts(0)}])
s = self.load()[0]
- self.assertEqual(s["p"], "-sin-cwd")
+ self.assertEqual(s["p"], "-no-cwd")
self.assertTrue(s["i"])
- def test_ignora_los_jsonl_de_subagentes(self):
+ def test_ignores_subagent_jsonl_files(self):
simple_tree(self.root)
sub = os.path.join(self.root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-000000000001", "subagents")
os.makedirs(sub)
with open(os.path.join(sub, "agent-1.jsonl"), "w", encoding="utf-8") as f:
- f.write(json.dumps(user("soy un subagente")) + "\n")
+ f.write(json.dumps(user("I am a subagent")) + "\n")
self.assertEqual(len(self.load()), 3)
@@ -159,18 +159,18 @@ class TestCache(TempRoot):
with open(self.cache, encoding="utf-8") as f:
blob = json.load(f)
for entry in blob["entries"].values():
- entry["rec"]["t"] = "vino del caché"
+ entry["rec"]["t"] = "came from the cache"
with open(self.cache, "w", encoding="utf-8") as f:
json.dump(blob, f)
- self.assertEqual(self.load()[0]["t"], "vino del caché")
+ self.assertEqual(self.load()[0]["t"], "came from the cache")
def test_reparses_if_the_file_changed(self):
path = write_session(self.root, "-p", "99999999-0000-0000-0000-000000000009",
[user("original", at=ts(0))])
self.load()
write_session(self.root, "-p", "99999999-0000-0000-0000-000000000009",
- [user("cambiado", at=ts(0)), user("y otro", at=ts(1))])
+ [user("changed", at=ts(0)), user("and another", at=ts(1))])
self.assertEqual(self.load()[0]["u"], 2)
self.assertTrue(os.path.exists(path))
@@ -181,16 +181,16 @@ class TestCache(TempRoot):
blob = json.load(f)
blob["v"] = S.CACHE_VERSION - 1
for entry in blob["entries"].values():
- entry["rec"]["t"] = "no debería verse"
+ entry["rec"]["t"] = "should not show up"
with open(self.cache, "w", encoding="utf-8") as f:
json.dump(blob, f)
- self.assertEqual(self.load()[0]["t"], "Arreglar el build")
+ self.assertEqual(self.load()[0]["t"], "Fix the build")
def test_broken_cache_breaks_nothing(self):
simple_tree(self.root)
with open(self.cache, "w", encoding="utf-8") as f:
- f.write("{esto no es json")
+ f.write("{this is not json")
self.assertEqual(len(self.load()), 3)
def test_no_cache_writes_nothing(self):
@@ -200,7 +200,7 @@ class TestCache(TempRoot):
def test_cache_stores_the_path_without_inferring(self):
write_session(self.root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-000000000001",
- [user("con cwd", at=ts(0))])
+ [user("with cwd", at=ts(0))])
write_session(self.root, "-home-u-proj", "dddddddd-0000-0000-0000-000000000004",
[{"type": "system", "timestamp": ts(30)}])
self.load()
@@ -226,7 +226,7 @@ class TestFilters(TempRoot):
self.sessions = self.load()
def test_by_project(self):
- out = S.apply_filters(self.sessions, project="/home/u/otro")
+ out = S.apply_filters(self.sessions, project="/home/u/other")
self.assertEqual(len(out), 1)
def test_by_conversation_content(self):
@@ -234,7 +234,7 @@ class TestFilters(TempRoot):
self.assertEqual([s["id"][:8] for s in out], ["aaaaaaaa"])
def test_by_title_path_branch_or_uuid(self):
- self.assertEqual(len(S.apply_filters(self.sessions, query="arreglar")), 1)
+ self.assertEqual(len(S.apply_filters(self.sessions, query="fix the")), 1)
self.assertEqual(len(S.apply_filters(self.sessions, query="main")), 2)
self.assertEqual(len(S.apply_filters(self.sessions, query="cccccccc")), 1)
@@ -266,7 +266,7 @@ class TestPick(TempRoot):
def test_ambiguous_prefix(self):
write_session(self.root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-0000000000ff",
- [user("otra más", at=ts(50))])
+ [user("one more", at=ts(50))])
with self.assertRaises(S.SessionError):
S.pick(self.load(), "aaaa")
@@ -290,7 +290,7 @@ class TestParseTs(unittest.TestCase):
def test_returns_none_if_unreadable(self):
self.assertIsNone(S.parse_ts(None))
self.assertIsNone(S.parse_ts(""))
- self.assertIsNone(S.parse_ts("ayer a la tarde"))
+ self.assertIsNone(S.parse_ts("yesterday afternoon"))
class TestRoots(unittest.TestCase):