diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-10-01 18:21:23 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-10-01 18:21:23 -0300 |
| commit | d3d0416b45698b9d40700b2196400542dc77c9ce (patch) | |
| tree | 165188602cb9c2545975b2573bb1906fcbfb7346 /tests | |
| parent | cbf81b04e57e03b9e1b646e0d0b7f7c1fd79acc2 (diff) | |
| download | claude-logbook-d3d0416b45698b9d40700b2196400542dc77c9ce.tar.gz claude-logbook-d3d0416b45698b9d40700b2196400542dc77c9ce.zip | |
Translate the CLI, the HTML page and the tests to English
Everything the user sees is now in English: help text and examples, table
headers, messages and errors, month names and relative dates, and every
string in the generated page. Tests, fixtures, workflow comments and
.gitignore follow. README.es.md stays as a Spanish translation of the docs.
Visible changes:
- --html writes sessions.html by default (sesiones.html stays ignored).
- The delete prompt is [y/N] and no longer accepts "s"/"si".
- The page stores the theme under cl-theme, so it is chosen again once.
- --check report keys and the --html summary keys are now English.
The --json format is unchanged.
Version 1.2.0.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fixtures.py | 46 | ||||
| -rw-r--r-- | tests/test_cli.py | 94 | ||||
| -rw-r--r-- | tests/test_memory.py | 80 | ||||
| -rw-r--r-- | tests/test_sessions.py | 66 | ||||
| -rw-r--r-- | tests/test_terminal.py | 78 | ||||
| -rw-r--r-- | tests/test_webpage.py | 40 |
6 files changed, 202 insertions, 202 deletions
diff --git a/tests/fixtures.py b/tests/fixtures.py index aef1d3f..0e288c8 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -56,23 +56,23 @@ def write_session(root, project_dir, session_id, events): def simple_tree(root): """A small, varied tree: a chat, an empty one and one without cwd.""" write_session(root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-000000000001", [ - ai_title("Arreglar el build"), - user("¿por qué falla el build?", at=ts(0)), - assistant("Miro el log.", tools=[("Bash", {"command": "make"})], at=ts(3)), - user("gracias", at=ts(12)), + ai_title("Fix the build"), + user("why does the build fail?", at=ts(0)), + assistant("Checking the log.", tools=[("Bash", {"command": "make"})], at=ts(3)), + user("thanks", at=ts(12)), ]) write_session(root, "-home-u-proj", "bbbbbbbb-0000-0000-0000-000000000002", [ {"type": "system", "timestamp": ts(0, hour=9), "cwd": "/home/u/proj"}, ]) - write_session(root, "-home-u-otro", "cccccccc-0000-0000-0000-000000000003", [ - user("hola", at=ts(0, hour=8), cwd="/home/u/otro"), + write_session(root, "-home-u-other", "cccccccc-0000-0000-0000-000000000003", [ + user("hello", at=ts(0, hour=8), cwd="/home/u/other"), ]) return root # ──────────────────────────────── memories ──────────────────────────────── -def write_memory(root, project_dir, name, body="cuerpo", desc=None, +def write_memory(root, project_dir, name, body="body text", desc=None, kind="project", origin=None, frontmatter=True): """Writes <project>/memory/<name>.md and returns its path.""" d = os.path.join(root, project_dir, "memory") @@ -81,14 +81,14 @@ def write_memory(root, project_dir, name, body="cuerpo", desc=None, parts = [] if frontmatter: - campos = ["---", f"name: {name}"] + fields = ["---", f"name: {name}"] if desc is not None: - campos.append(f"description: {desc}") - campos += ["metadata:", " node_type: memory", f" type: {kind}"] + fields.append(f"description: {desc}") + fields += ["metadata:", " node_type: memory", f" type: {kind}"] if origin: - campos.append(f" originSessionId: {origin}") - campos.append("---") - parts.append("\n".join(campos)) + fields.append(f" originSessionId: {origin}") + fields.append("---") + parts.append("\n".join(fields)) parts.append(body) with open(path, "w", encoding="utf-8") as f: @@ -102,7 +102,7 @@ def write_index(root, project_dir, names, extra=()): os.makedirs(d, exist_ok=True) lines = ["# Memory Index", ""] for n in list(names) + list(extra): - lines.append(f"- [{n}]({n}.md) — pista de {n}") + lines.append(f"- [{n}]({n}.md) — hint for {n}") path = os.path.join(d, "MEMORY.md") with open(path, "w", encoding="utf-8") as f: f.write("\n".join(lines) + "\n") @@ -112,22 +112,22 @@ def write_index(root, project_dir, names, extra=()): def memory_tree(root): """Varied memories: indexed, unlisted, and a project without an index.""" write_memory(root, "-home-u-proj", "deploy-docker", - body="Se despliega con `make up`.\nVer [[roles-db]] y [[no-existe]].", - desc="Cómo se despliega el proyecto", + body="Deployed with `make up`.\nSee [[roles-db]] and [[missing]].", + desc="How the project is deployed", origin="aaaaaaaa-0000-0000-0000-000000000001") - write_memory(root, "-home-u-proj", "roles-db", body="Roles de la base.", + write_memory(root, "-home-u-proj", "roles-db", body="Database roles.", desc="Roles", kind="reference") - write_memory(root, "-home-u-proj", "suelta", body="No está en el índice.", - desc="Huérfana") + write_memory(root, "-home-u-proj", "stray", body="Not in the index.", + desc="Orphan") # The index lists two real ones and one that no longer exists. write_index(root, "-home-u-proj", ["deploy-docker", "roles-db"], - extra=["borrada-hace-rato"]) + extra=["deleted-long-ago"]) # Another project with memory but no MEMORY.md. - write_memory(root, "-home-u-otro", "sin-indice", body="Nadie me indexa.", - desc="Sin índice", kind="user", + write_memory(root, "-home-u-other", "no-index", body="Nobody indexes me.", + desc="No index", kind="user", origin="ffffffff-0000-0000-0000-00000000000f") # An empty memory/ does not count as a project with memory. - os.makedirs(os.path.join(root, "-home-u-vacio", "memory"), exist_ok=True) + os.makedirs(os.path.join(root, "-home-u-empty", "memory"), exist_ok=True) return root diff --git a/tests/test_cli.py b/tests/test_cli.py index 7b52177..204038c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -41,41 +41,41 @@ class CliCase(unittest.TestCase): return code, out.getvalue(), err.getvalue() -class TestTabla(CliCase): +class TestTable(CliCase): def test_lists_the_sessions(self): simple_tree(self.root) code, out, _ = self.run_cli() self.assertEqual(code, 0) - self.assertIn("Arreglar el build", out) - self.assertIn("3 sesiones · 2 proyectos", out) + self.assertIn("Fix the build", out) + self.assertIn("3 sessions · 2 projects", out) def test_filters_by_text(self): simple_tree(self.root) - code, out, _ = self.run_cli("arreglar") + code, out, _ = self.run_cli("fix the") self.assertEqual(code, 0) - self.assertIn("1 de 3 sesiones", out) + self.assertIn("1 of 3 sessions", out) def test_limits_the_count(self): simple_tree(self.root) _, out, _ = self.run_cli("-n", "1") - self.assertIn("1 de 3 sesiones", out) + self.assertIn("1 of 3 sessions", out) def test_filter_without_results_exits_with_1(self): simple_tree(self.root) - code, _, err = self.run_cli("no-existe-esto") + code, _, err = self.run_cli("nothing-like-this") self.assertEqual(code, 1) - self.assertIn("Ninguna sesión coincide", err) + self.assertIn("No session matches", err) def test_no_claude_directory_exits_with_2(self): - with unittest.mock.patch.dict(os.environ, {"CLAUDE_CONFIG_DIR": "/no/existe"}): + with unittest.mock.patch.dict(os.environ, {"CLAUDE_CONFIG_DIR": "/does/not/exist"}): code, _, err = self.run_cli() self.assertEqual(code, 2) - self.assertIn("no existe", err) + self.assertIn("does not exist", err) def test_no_session_exits_with_1(self): code, _, err = self.run_cli() self.assertEqual(code, 1) - self.assertIn("No hay ninguna sesión", err) + self.assertIn("No sessions recorded", err) class TestExport(CliCase): @@ -93,7 +93,7 @@ class TestExport(CliCase): out_path = os.path.join(self.home, "s.html") code, _, err = self.run_cli("--html", out_path) self.assertEqual(code, 0) - self.assertIn("3 sesiones", err) + self.assertIn("3 sessions", err) with open(out_path, encoding="utf-8") as f: html = f.read() payload = json.loads(PAYLOAD_RE.findall(html)[0]) @@ -112,23 +112,23 @@ class TestReading(CliCase): simple_tree(self.root) code, out, _ = self.run_cli("-s", "1", "--no-pager") self.assertEqual(code, 0) - self.assertIn("¿por qué falla el build?", out) + self.assertIn("why does the build fail?", out) def test_show_by_uuid_prefix(self): simple_tree(self.root) _, out, _ = self.run_cli("-s", "cccccccc", "--no-pager") - self.assertIn("hola", out) + self.assertIn("hello", out) def test_show_honours_the_previous_filter(self): simple_tree(self.root) - _, out, _ = self.run_cli("-p", "/home/u/otro", "-s", "1", "--no-pager") - self.assertIn("hola", out) + _, out, _ = self.run_cli("-p", "/home/u/other", "-s", "1", "--no-pager") + self.assertIn("hello", out) def test_missing_reference_exits_with_2(self): simple_tree(self.root) code, _, err = self.run_cli("-s", "99") self.assertEqual(code, 2) - self.assertIn("fuera de rango", err) + self.assertIn("out of range", err) def test_resume_prints_the_command(self): simple_tree(self.root) @@ -145,17 +145,17 @@ class TestDeletion(CliCase): def test_dry_run_touches_nothing(self): simple_tree(self.root) - antes = self.paths() + before = self.paths() code, out, _ = self.run_cli("--delete-empty", "--dry-run") self.assertEqual(code, 0) - self.assertIn("no se tocó nada", out) - self.assertEqual(self.paths(), antes) + self.assertIn("nothing was touched", out) + self.assertEqual(self.paths(), before) def test_deletes_the_empty_ones(self): simple_tree(self.root) code, out, _ = self.run_cli("--delete-empty", "-y") self.assertEqual(code, 0) - self.assertIn("1 sesión borrada", out) + self.assertIn("1 session deleted", out) self.assertEqual(self.paths(), ["aaaaaaaa-0000-0000-0000-000000000001.jsonl"]) @@ -170,32 +170,32 @@ class TestDeletion(CliCase): simple_tree(self.root) code, out, _ = self.run_cli("-D", "aaaaaaaa", "1", "-y") self.assertEqual(code, 0) - self.assertIn("1 sesión borrada", out) + self.assertIn("1 session deleted", out) def test_deleted_one_does_not_come_back_from_cache(self): simple_tree(self.root) self.run_cli() # fills the cache self.run_cli("--delete-empty", "-y") _, out, _ = self.run_cli() - self.assertIn("2 sesiones", out) + self.assertIn("2 sessions", out) self.assertNotIn("bbbbbbbb", out) def test_filter_limits_what_is_deleted(self): - write_session(self.root, "-home-u-otro", "ffffffff-0000-0000-0000-000000000006", + write_session(self.root, "-home-u-other", "ffffffff-0000-0000-0000-000000000006", [{"type": "system", "timestamp": ts(0)}]) simple_tree(self.root) code, out, _ = self.run_cli("-p", "/home/u/proj", "--delete-empty", "-y") self.assertEqual(code, 0) - self.assertIn("1 sesión borrada", out) + self.assertIn("1 session deleted", out) self.assertTrue(os.path.exists(os.path.join( - self.root, "-home-u-otro", "ffffffff-0000-0000-0000-000000000006.jsonl"))) + self.root, "-home-u-other", "ffffffff-0000-0000-0000-000000000006.jsonl"))) def test_nothing_to_delete_warns(self): write_session(self.root, "-p", "aaaaaaaa-0000-0000-0000-000000000001", - [user("hola", at=ts(0))]) + [user("hello", at=ts(0))]) code, _, err = self.run_cli("--delete-empty", "-y") self.assertEqual(code, 0) - self.assertIn("No hay sesiones que borrar", err) + self.assertIn("No sessions to delete", err) class TestParser(unittest.TestCase): @@ -203,29 +203,29 @@ class TestParser(unittest.TestCase): args = cli.build_parser().parse_args(["--html"]) self.assertEqual(args.html, cli.DEFAULT_HTML) - def test_html_con_valor(self): + def test_html_with_value(self): self.assertEqual(cli.build_parser().parse_args(["--html", "x.html"]).html, "x.html") def test_query_joins_the_words(self): - args = cli.build_parser().parse_args(["dos", "palabras"]) - self.assertEqual(args.query, ["dos", "palabras"]) + args = cli.build_parser().parse_args(["two", "words"]) + self.assertEqual(args.query, ["two", "words"]) class TestMemory(CliCase): - def test_tabla(self): + def test_table(self): simple_tree(self.root) memory_tree(self.root) code, out, _ = self.run_cli("-m") self.assertEqual(code, 0) self.assertIn("deploy-docker", out) - self.assertIn("4 memorias", out) + self.assertIn("4 memories", out) def test_no_memories_warns(self): simple_tree(self.root) code, _, err = self.run_cli("-m") self.assertEqual(code, 1) - self.assertIn("memorias", err) + self.assertIn("memories", err) def test_filters_by_type(self): simple_tree(self.root) @@ -248,13 +248,13 @@ class TestMemory(CliCase): memory_tree(self.root) code, out, _ = self.run_cli("-m", "-s", "deploy", "--no-pager") self.assertEqual(code, 0) - self.assertIn("Se despliega con", out) + self.assertIn("Deployed with", out) self.assertIn("deploy-docker", out) def test_show_warns_if_not_indexed(self): simple_tree(self.root) memory_tree(self.root) - _, out, _ = self.run_cli("-m", "-s", "suelta", "--no-pager") + _, out, _ = self.run_cli("-m", "-s", "stray", "--no-pager") self.assertIn("MEMORY.md", out) def test_check_lists_the_problems(self): @@ -262,17 +262,17 @@ class TestMemory(CliCase): memory_tree(self.root) code, out, _ = self.run_cli("-m", "--check") self.assertEqual(code, 1) # there are things to look at - self.assertIn("sin MEMORY.md", out) - self.assertIn("no-existe", out) + self.assertIn("no MEMORY.md", out) + self.assertIn("missing", out) def test_clean_check_exits_zero(self): simple_tree(self.root) - write_memory(self.root, "-home-u-proj", "sola", body="sin enlaces") + write_memory(self.root, "-home-u-proj", "lone", body="no links") from .fixtures import write_index - write_index(self.root, "-home-u-proj", ["sola"]) + write_index(self.root, "-home-u-proj", ["lone"]) code, out, _ = self.run_cli("-m", "--check") self.assertEqual(code, 0) - self.assertIn("Todo en orden", out) + self.assertIn("All good", out) def test_dry_run_deletion_touches_nothing(self): simple_tree(self.root) @@ -281,7 +281,7 @@ class TestMemory(CliCase): "deploy-docker.md") code, out, _ = self.run_cli("-m", "-D", "deploy", "--dry-run") self.assertEqual(code, 0) - self.assertIn("no se tocó nada", out) + self.assertIn("nothing was touched", out) self.assertTrue(os.path.exists(path)) def test_deletes_and_unindexes(self): @@ -297,7 +297,7 @@ class TestMemory(CliCase): index = f.read() self.assertNotIn("deploy-docker.md", index) self.assertIn("roles-db.md", index) - self.assertIn("sacadas del índice", out) + self.assertIn("removed from the index", out) def test_unconfirmed_deletion_cancels(self): simple_tree(self.root) @@ -307,15 +307,15 @@ class TestMemory(CliCase): with unittest.mock.patch.object(cli, "confirm", return_value=False): code, _, err = self.run_cli("-m", "-D", "deploy") self.assertEqual(code, 1) - self.assertIn("Cancelado", err) + self.assertIn("Cancelled", err) self.assertTrue(os.path.exists(path)) def test_missing_reference(self): simple_tree(self.root) memory_tree(self.root) - code, _, err = self.run_cli("-m", "-s", "no-existe-nada") + code, _, err = self.run_cli("-m", "-s", "no-such-memory") self.assertEqual(code, 2) - self.assertIn("ninguna memoria", err) + self.assertIn("no memory matches", err) def test_html_embeds_the_memories(self): simple_tree(self.root) @@ -323,7 +323,7 @@ class TestMemory(CliCase): out_path = os.path.join(self.home, "s.html") code, _, err = self.run_cli("--html", out_path) self.assertEqual(code, 0) - self.assertIn("4 memorias", err) + self.assertIn("4 memories", err) with open(out_path, encoding="utf-8") as f: payload = json.loads(PAYLOAD_RE.findall(f.read())[0]) self.assertEqual(len(payload["m"]), 4) diff --git a/tests/test_memory.py b/tests/test_memory.py index 460d4ec..8761b3e 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -26,36 +26,36 @@ class MemoryCase(unittest.TestCase): class TestParsing(MemoryCase): def test_reads_frontmatter_and_body(self): - path = write_memory(self.root, "-home-u-proj", "una", - body="el cuerpo", desc="qué es", kind="feedback", + path = write_memory(self.root, "-home-u-proj", "one", + body="the body", desc="what it is", kind="feedback", origin="abc123") m = memory.read_memory(path, "-home-u-proj") - self.assertEqual(m["name"], "una") - self.assertEqual(m["desc"], "qué es") + self.assertEqual(m["name"], "one") + self.assertEqual(m["desc"], "what it is") self.assertEqual(m["ty"], "feedback") self.assertEqual(m["src"], "abc123") - self.assertEqual(m["body"], "el cuerpo") + self.assertEqual(m["body"], "the body") def test_quoted_description_loses_the_escapes(self): # Claude writes the description as a YAML string when it contains quotes. path = write_memory(self.root, "-home-u-proj", "q", - desc=r'"la máquina \"legion\" y algo"') + desc=r'"the \"legion\" machine and more"') self.assertEqual(memory.read_memory(path, "-home-u-proj")["desc"], - 'la máquina "legion" y algo') + 'the "legion" machine and more') def test_no_frontmatter_falls_back_to_the_file_name(self): - path = write_memory(self.root, "-home-u-proj", "pelada", - body="solo texto", frontmatter=False) + path = write_memory(self.root, "-home-u-proj", "bare", + body="just text", frontmatter=False) m = memory.read_memory(path, "-home-u-proj") - self.assertEqual(m["name"], "pelada") + self.assertEqual(m["name"], "bare") self.assertEqual(m["ty"], "—") - self.assertEqual(m["body"], "solo texto") + self.assertEqual(m["body"], "just text") def test_collects_links_without_repeats(self): path = write_memory(self.root, "-home-u-proj", "l", - body="[[uno]] y [[dos]] y otra vez [[uno]]") + body="[[one]] and [[two]] and again [[one]]") self.assertEqual(memory.read_memory(path, "-home-u-proj")["ln"], - ["dos", "uno"]) + ["one", "two"]) class TestLoading(MemoryCase): @@ -77,16 +77,16 @@ class TestLoading(MemoryCase): def test_ignores_empty_memory_directories(self): memory_tree(self.root) _, mems = self.load_items() - self.assertNotIn("-home-u-vacio", {m["project_dir"] for m in mems}) + self.assertNotIn("-home-u-empty", {m["project_dir"] for m in mems}) def test_marks_what_is_in_the_index(self): memory_tree(self.root) _, mems = self.load_items() by_name = {m["name"]: m for m in mems} self.assertTrue(by_name["deploy-docker"]["ix"]) - self.assertFalse(by_name["suelta"]["ix"]) - self.assertTrue(by_name["suelta"]["hix"]) - self.assertFalse(by_name["sin-indice"]["hix"]) + self.assertFalse(by_name["stray"]["ix"]) + self.assertTrue(by_name["stray"]["hix"]) + self.assertFalse(by_name["no-index"]["hix"]) def test_sorts_by_date_descending(self): memory_tree(self.root) @@ -116,15 +116,15 @@ class TestFilters(MemoryCase): def test_by_project(self): r = memory.apply_filters(self.mems, project="/home/u/proj") - self.assertNotIn("sin-indice", [m["name"] for m in r]) + self.assertNotIn("no-index", [m["name"] for m in r]) def test_query_reaches_the_body(self): r = memory.apply_filters(self.mems, query="make up") self.assertEqual([m["name"] for m in r], ["deploy-docker"]) def test_query_also_checks_the_description(self): - r = memory.apply_filters(self.mems, query="huérfana") - self.assertEqual([m["name"] for m in r], ["suelta"]) + r = memory.apply_filters(self.mems, query="orphan") + self.assertEqual([m["name"] for m in r], ["stray"]) class TestPick(MemoryCase): @@ -146,16 +146,16 @@ class TestPick(MemoryCase): def test_falls_back_to_substring(self): self.assertEqual(memory.pick(self.mems, "docker")["name"], "deploy-docker") - def test_sin_coincidencias(self): + def test_no_matches(self): with self.assertRaises(sessions.SessionError): - memory.pick(self.mems, "nada-que-ver") + memory.pick(self.mems, "nothing-like-it") def test_ambiguous(self): - write_memory(self.root, "-home-u-proj", "deploy-otro") + write_memory(self.root, "-home-u-proj", "deploy-other") _, mems = self.load_items() with self.assertRaises(sessions.SessionError) as ctx: memory.pick(mems, "deploy") - self.assertIn("ambiguo", str(ctx.exception)) + self.assertIn("ambiguous", str(ctx.exception)) class TestAudit(MemoryCase): @@ -167,31 +167,31 @@ class TestAudit(MemoryCase): self.report = memory.audit(self.mems, self.ss, root=self.root) def test_project_without_index(self): - self.assertEqual([m["name"] for m in self.report["sin_indice"]], - ["sin-indice"]) + self.assertEqual([m["name"] for m in self.report["no_index"]], + ["no-index"]) def test_memory_outside_the_index(self): - self.assertEqual([m["name"] for m in self.report["sin_listar"]], - ["suelta"]) + self.assertEqual([m["name"] for m in self.report["unlisted"]], + ["stray"]) def test_index_entry_without_file(self): - self.assertEqual([n for _, n in self.report["indice_fantasma"]], - ["borrada-hace-rato"]) + self.assertEqual([n for _, n in self.report["ghost_entries"]], + ["deleted-long-ago"]) def test_broken_link(self): - broken = [link for _, link in self.report["enlaces_rotos"]] - self.assertEqual(broken, ["no-existe"]) # [[roles-db]] does resolve + broken = [link for _, link in self.report["broken_links"]] + self.assertEqual(broken, ["missing"]) # [[roles-db]] does resolve def test_lost_origin_session(self): - # deploy-docker points to a session that exists; sin-indice does not. - self.assertEqual([m["name"] for m in self.report["origen_perdido"]], - ["sin-indice"]) + # deploy-docker points to a session that exists; no-index does not. + self.assertEqual([m["name"] for m in self.report["lost_source"]], + ["no-index"]) def test_consistent_tree_reports_nothing(self): - is_clean = os.path.join(self._tmp.name, "limpio") + is_clean = os.path.join(self._tmp.name, "clean") os.makedirs(is_clean) - write_memory(is_clean, "-p", "sola", body="sin enlaces") - write_index(is_clean, "-p", ["sola"]) + write_memory(is_clean, "-p", "lone", body="no links") + write_index(is_clean, "-p", ["lone"]) mems = memory.load_memories([], root=is_clean) self.assertEqual(memory.audit_total(memory.audit(mems, [], root=is_clean)), 0) @@ -217,12 +217,12 @@ class TestDeletion(MemoryCase): self.assertIn("roles-db", memory.read_index("-home-u-proj", self.root)) def test_delete_one_that_was_not_indexed(self): - m = self.by_name("suelta") + m = self.by_name("stray") self.assertFalse(memory.delete(m, root=self.root)) self.assertFalse(os.path.exists(memory.memory_path(m, self.root))) def test_delete_without_memory_md(self): - m = self.by_name("sin-indice") + m = self.by_name("no-index") self.assertFalse(memory.delete(m, root=self.root)) self.assertFalse(os.path.exists(memory.memory_path(m, self.root))) 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): diff --git a/tests/test_terminal.py b/tests/test_terminal.py index 6991a85..0446dda 100644 --- a/tests/test_terminal.py +++ b/tests/test_terminal.py @@ -22,11 +22,11 @@ class TestStyle(unittest.TestCase): st = T.Style(True) self.assertTrue(st.amber.startswith("\x1b[")) - def test_un_color_que_no_existe_es_attribute_error(self): + def test_unknown_color_is_attribute_error(self): with self.assertRaises(AttributeError): - T.Style(True).fucsia + T.Style(True).fuchsia - def test_from_stream_sin_tty_apaga_el_color(self): + def test_from_stream_without_tty_turns_color_off(self): self.assertFalse(T.Style.from_stream(io.StringIO()).on) @@ -39,27 +39,27 @@ class TestFormatting(unittest.TestCase): self.assertEqual(T.fmt_dur(125), "2h05") def test_fmt_rel(self): - self.assertEqual(T.fmt_rel(ago(0.2), NOW), "hoy") - self.assertEqual(T.fmt_rel(ago(1.5), NOW), "ayer") - self.assertEqual(T.fmt_rel(ago(3), NOW), "hace 3d") - self.assertEqual(T.fmt_rel(ago(10), NOW), "hace 1sem") - self.assertEqual(T.fmt_rel(ago(70), NOW), "hace 2mes") + self.assertEqual(T.fmt_rel(ago(0.2), NOW), "today") + self.assertEqual(T.fmt_rel(ago(1.5), NOW), "yesterday") + self.assertEqual(T.fmt_rel(ago(3), NOW), "3d ago") + self.assertEqual(T.fmt_rel(ago(10), NOW), "1w ago") + self.assertEqual(T.fmt_rel(ago(70), NOW), "2mo ago") def test_fmt_size(self): self.assertEqual(T.fmt_size(12.5), "12.5 KB") self.assertEqual(T.fmt_size(2048), "2.0 MB") def test_clip(self): - self.assertEqual(T.clip("hola", 10), "hola") - self.assertEqual(T.clip("hola mundo", 6), "hola …") - self.assertEqual(T.clip("con\nsalto", 20), "con salto") + self.assertEqual(T.clip("hello", 10), "hello") + self.assertEqual(T.clip("hello world", 6), "hello…") + self.assertEqual(T.clip("line\nbreak", 20), "line break") def test_visible_len_ignores_ansi_codes(self): - self.assertEqual(T.visible_len("\x1b[1mhola\x1b[0m"), 4) + self.assertEqual(T.visible_len("\x1b[1mhello\x1b[0m"), 5) def test_plural(self): - se |