aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2026-09-26 23:33:28 -0300
committerElvis Claros Castro <elvis@claros.ar>2026-09-26 23:33:28 -0300
commitcbf81b04e57e03b9e1b646e0d0b7f7c1fd79acc2 (patch)
treee62f57de5831167bccdc7eb9007ad0bfc9bee4e7 /tests
parent82ab6d5f70e5067a32ba7ad5db5786322c9fef5f (diff)
downloadclaude-logbook-cbf81b04e57e03b9e1b646e0d0b7f7c1fd79acc2.tar.gz
claude-logbook-cbf81b04e57e03b9e1b646e0d0b7f7c1fd79acc2.zip
Translate identifiers, comments and docstrings to EnglishHEADmain
The CLI output and help stay in Spanish, as documented in the README.
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures.py28
-rw-r--r--tests/test_cli.py82
-rw-r--r--tests/test_memory.py146
-rw-r--r--tests/test_sessions.py82
-rw-r--r--tests/test_terminal.py78
-rw-r--r--tests/test_webpage.py68
6 files changed, 242 insertions, 242 deletions
diff --git a/tests/fixtures.py b/tests/fixtures.py
index 52d5447..aef1d3f 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -1,4 +1,4 @@
-"""Sesiones .jsonl de mentira para los tests."""
+"""Fake .jsonl sessions for the tests."""
import json
import os
@@ -43,7 +43,7 @@ def ai_title(title, at=BASE_TS):
def write_session(root, project_dir, session_id, events):
- """Escribe un .jsonl y devuelve su ruta."""
+ """Writes a .jsonl and returns its path."""
d = os.path.join(root, project_dir)
os.makedirs(d, exist_ok=True)
path = os.path.join(d, session_id + ".jsonl")
@@ -54,7 +54,7 @@ def write_session(root, project_dir, session_id, events):
def simple_tree(root):
- """Un árbol chico y variado: una charla, una vacía y una sin cwd."""
+ """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)),
@@ -70,16 +70,16 @@ def simple_tree(root):
return root
-# ──────────────────────────────── memorias ────────────────────────────────
+# ──────────────────────────────── memories ────────────────────────────────
def write_memory(root, project_dir, name, body="cuerpo", desc=None,
kind="project", origin=None, frontmatter=True):
- """Escribe <proyecto>/memory/<name>.md y devuelve su ruta."""
+ """Writes <project>/memory/<name>.md and returns its path."""
d = os.path.join(root, project_dir, "memory")
os.makedirs(d, exist_ok=True)
path = os.path.join(d, name + ".md")
- partes = []
+ parts = []
if frontmatter:
campos = ["---", f"name: {name}"]
if desc is not None:
@@ -88,16 +88,16 @@ def write_memory(root, project_dir, name, body="cuerpo", desc=None,
if origin:
campos.append(f" originSessionId: {origin}")
campos.append("---")
- partes.append("\n".join(campos))
- partes.append(body)
+ parts.append("\n".join(campos))
+ parts.append(body)
with open(path, "w", encoding="utf-8") as f:
- f.write("\n".join(partes) + "\n")
+ f.write("\n".join(parts) + "\n")
return path
def write_index(root, project_dir, names, extra=()):
- """Escribe el MEMORY.md que enlaza esos nombres."""
+ """Writes the MEMORY.md that links those names."""
d = os.path.join(root, project_dir, "memory")
os.makedirs(d, exist_ok=True)
lines = ["# Memory Index", ""]
@@ -110,7 +110,7 @@ def write_index(root, project_dir, names, extra=()):
def memory_tree(root):
- """Memorias variadas: indexada, sin listar, y un proyecto sin índice."""
+ """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",
@@ -119,15 +119,15 @@ def memory_tree(root):
desc="Roles", kind="reference")
write_memory(root, "-home-u-proj", "suelta", body="No está en el índice.",
desc="Huérfana")
- # El índice lista dos reales y una que ya no existe.
+ # 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"])
- # Otro proyecto con memoria pero sin MEMORY.md.
+ # 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",
origin="ffffffff-0000-0000-0000-00000000000f")
- # Un memory/ vacío no cuenta como proyecto con memoria.
+ # An empty memory/ does not count as a project with memory.
os.makedirs(os.path.join(root, "-home-u-vacio", "memory"), exist_ok=True)
return root
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 94d472d..7b52177 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -18,7 +18,7 @@ PAYLOAD_RE = re.compile(
class CliCase(unittest.TestCase):
- """Cada test corre contra un ~/.claude y un caché de mentira."""
+ """Each test runs against a fake ~/.claude and cache."""
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
@@ -42,43 +42,43 @@ class CliCase(unittest.TestCase):
class TestTabla(CliCase):
- def test_lista_las_sesiones(self):
+ 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)
- def test_filtra_por_texto(self):
+ def test_filters_by_text(self):
simple_tree(self.root)
code, out, _ = self.run_cli("arreglar")
self.assertEqual(code, 0)
self.assertIn("1 de 3 sesiones", out)
- def test_limita_la_cantidad(self):
+ def test_limits_the_count(self):
simple_tree(self.root)
_, out, _ = self.run_cli("-n", "1")
self.assertIn("1 de 3 sesiones", out)
- def test_un_filtro_sin_resultados_sale_con_1(self):
+ def test_filter_without_results_exits_with_1(self):
simple_tree(self.root)
code, _, err = self.run_cli("no-existe-esto")
self.assertEqual(code, 1)
self.assertIn("Ninguna sesión coincide", err)
- def test_sin_directorio_de_claude_sale_con_2(self):
+ def test_no_claude_directory_exits_with_2(self):
with unittest.mock.patch.dict(os.environ, {"CLAUDE_CONFIG_DIR": "/no/existe"}):
code, _, err = self.run_cli()
self.assertEqual(code, 2)
self.assertIn("no existe", err)
- def test_sin_ninguna_sesion_sale_con_1(self):
+ 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)
-class TestExportar(CliCase):
+class TestExport(CliCase):
def test_json(self):
simple_tree(self.root)
code, out, _ = self.run_cli("--json")
@@ -100,37 +100,37 @@ class TestExportar(CliCase):
self.assertEqual(len(payload["s"]), 3)
self.assertEqual(payload["m"], [])
- def test_html_no_toca_stdout(self):
- # El resumen va a stderr para que `--html /dev/stdout` siga sirviendo.
+ def test_html_leaves_stdout_alone(self):
+ # The summary goes to stderr so `--html /dev/stdout` keeps working.
simple_tree(self.root)
_, out, _ = self.run_cli("--html", os.path.join(self.home, "s.html"))
self.assertEqual(out, "")
-class TestLectura(CliCase):
- def test_show_por_indice(self):
+class TestReading(CliCase):
+ def test_show_by_index(self):
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)
- def test_show_por_prefijo_de_uuid(self):
+ def test_show_by_uuid_prefix(self):
simple_tree(self.root)
_, out, _ = self.run_cli("-s", "cccccccc", "--no-pager")
self.assertIn("hola", out)
- def test_show_respeta_el_filtro_previo(self):
+ 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)
- def test_una_referencia_que_no_existe_sale_con_2(self):
+ 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)
- def test_resume_imprime_el_comando(self):
+ def test_resume_prints_the_command(self):
simple_tree(self.root)
code, out, _ = self.run_cli("-r", "1")
self.assertEqual(code, 0)
@@ -139,11 +139,11 @@ class TestLectura(CliCase):
"aaaaaaaa-0000-0000-0000-000000000001")
-class TestBorrado(CliCase):
+class TestDeletion(CliCase):
def paths(self):
return sorted(os.listdir(os.path.join(self.root, "-home-u-proj")))
- def test_dry_run_no_toca_nada(self):
+ def test_dry_run_touches_nothing(self):
simple_tree(self.root)
antes = self.paths()
code, out, _ = self.run_cli("--delete-empty", "--dry-run")
@@ -151,7 +151,7 @@ class TestBorrado(CliCase):
self.assertIn("no se tocó nada", out)
self.assertEqual(self.paths(), antes)
- def test_borra_las_vacias(self):
+ def test_deletes_the_empty_ones(self):
simple_tree(self.root)
code, out, _ = self.run_cli("--delete-empty", "-y")
self.assertEqual(code, 0)
@@ -159,28 +159,28 @@ class TestBorrado(CliCase):
self.assertEqual(self.paths(),
["aaaaaaaa-0000-0000-0000-000000000001.jsonl"])
- def test_borra_una_puntual_por_prefijo(self):
+ def test_deletes_a_single_one_by_prefix(self):
simple_tree(self.root)
code, _, _ = self.run_cli("-D", "aaaaaaaa", "-y")
self.assertEqual(code, 0)
self.assertEqual(self.paths(),
["bbbbbbbb-0000-0000-0000-000000000002.jsonl"])
- def test_no_repite_si_la_pediste_dos_veces(self):
+ def test_no_repeat_if_requested_twice(self):
simple_tree(self.root)
code, out, _ = self.run_cli("-D", "aaaaaaaa", "1", "-y")
self.assertEqual(code, 0)
self.assertIn("1 sesión borrada", out)
- def test_la_borrada_no_vuelve_desde_el_cache(self):
+ def test_deleted_one_does_not_come_back_from_cache(self):
simple_tree(self.root)
- self.run_cli() # llena el caché
+ self.run_cli() # fills the cache
self.run_cli("--delete-empty", "-y")
_, out, _ = self.run_cli()
self.assertIn("2 sesiones", out)
self.assertNotIn("bbbbbbbb", out)
- def test_el_filtro_acota_lo_que_se_borra(self):
+ def test_filter_limits_what_is_deleted(self):
write_session(self.root, "-home-u-otro", "ffffffff-0000-0000-0000-000000000006",
[{"type": "system", "timestamp": ts(0)}])
simple_tree(self.root)
@@ -190,7 +190,7 @@ class TestBorrado(CliCase):
self.assertTrue(os.path.exists(os.path.join(
self.root, "-home-u-otro", "ffffffff-0000-0000-0000-000000000006.jsonl")))
- def test_sin_nada_para_borrar_avisa(self):
+ def test_nothing_to_delete_warns(self):
write_session(self.root, "-p", "aaaaaaaa-0000-0000-0000-000000000001",
[user("hola", at=ts(0))])
code, _, err = self.run_cli("--delete-empty", "-y")
@@ -199,7 +199,7 @@ class TestBorrado(CliCase):
class TestParser(unittest.TestCase):
- def test_html_sin_valor_usa_el_nombre_por_defecto(self):
+ def test_html_without_value_uses_the_default_name(self):
args = cli.build_parser().parse_args(["--html"])
self.assertEqual(args.html, cli.DEFAULT_HTML)
@@ -207,12 +207,12 @@ class TestParser(unittest.TestCase):
self.assertEqual(cli.build_parser().parse_args(["--html", "x.html"]).html,
"x.html")
- def test_la_query_junta_las_palabras(self):
+ def test_query_joins_the_words(self):
args = cli.build_parser().parse_args(["dos", "palabras"])
self.assertEqual(args.query, ["dos", "palabras"])
-class TestMemoria(CliCase):
+class TestMemory(CliCase):
def test_tabla(self):
simple_tree(self.root)
memory_tree(self.root)
@@ -221,13 +221,13 @@ class TestMemoria(CliCase):
self.assertIn("deploy-docker", out)
self.assertIn("4 memorias", out)
- def test_sin_memorias_avisa(self):
+ def test_no_memories_warns(self):
simple_tree(self.root)
code, _, err = self.run_cli("-m")
self.assertEqual(code, 1)
self.assertIn("memorias", err)
- def test_filtra_por_tipo(self):
+ def test_filters_by_type(self):
simple_tree(self.root)
memory_tree(self.root)
code, out, _ = self.run_cli("-m", "--type", "reference")
@@ -235,7 +235,7 @@ class TestMemoria(CliCase):
self.assertIn("roles-db", out)
self.assertNotIn("deploy-docker", out)
- def test_la_query_busca_en_el_cuerpo(self):
+ def test_query_searches_the_body(self):
simple_tree(self.root)
memory_tree(self.root)
code, out, _ = self.run_cli("-m", "make up")
@@ -243,7 +243,7 @@ class TestMemoria(CliCase):
self.assertIn("deploy-docker", out)
self.assertNotIn("roles-db", out)
- def test_show_por_nombre(self):
+ def test_show_by_name(self):
simple_tree(self.root)
memory_tree(self.root)
code, out, _ = self.run_cli("-m", "-s", "deploy", "--no-pager")
@@ -251,21 +251,21 @@ class TestMemoria(CliCase):
self.assertIn("Se despliega con", out)
self.assertIn("deploy-docker", out)
- def test_show_avisa_si_no_esta_indexada(self):
+ 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")
self.assertIn("MEMORY.md", out)
- def test_check_lista_los_problemas(self):
+ def test_check_lists_the_problems(self):
simple_tree(self.root)
memory_tree(self.root)
code, out, _ = self.run_cli("-m", "--check")
- self.assertEqual(code, 1) # hay cosas para mirar
+ self.assertEqual(code, 1) # there are things to look at
self.assertIn("sin MEMORY.md", out)
self.assertIn("no-existe", out)
- def test_check_limpio_sale_cero(self):
+ def test_clean_check_exits_zero(self):
simple_tree(self.root)
write_memory(self.root, "-home-u-proj", "sola", body="sin enlaces")
from .fixtures import write_index
@@ -274,7 +274,7 @@ class TestMemoria(CliCase):
self.assertEqual(code, 0)
self.assertIn("Todo en orden", out)
- def test_borrado_en_seco_no_toca_nada(self):
+ def test_dry_run_deletion_touches_nothing(self):
simple_tree(self.root)
memory_tree(self.root)
path = os.path.join(self.root, "-home-u-proj", "memory",
@@ -284,7 +284,7 @@ class TestMemoria(CliCase):
self.assertIn("no se tocó nada", out)
self.assertTrue(os.path.exists(path))
- def test_borra_y_desindexa(self):
+ def test_deletes_and_unindexes(self):
simple_tree(self.root)
memory_tree(self.root)
path = os.path.join(self.root, "-home-u-proj", "memory",
@@ -299,7 +299,7 @@ class TestMemoria(CliCase):
self.assertIn("roles-db.md", index)
self.assertIn("sacadas del índice", out)
- def test_borrado_sin_confirmar_cancela(self):
+ def test_unconfirmed_deletion_cancels(self):
simple_tree(self.root)
memory_tree(self.root)
path = os.path.join(self.root, "-home-u-proj", "memory",
@@ -310,14 +310,14 @@ class TestMemoria(CliCase):
self.assertIn("Cancelado", err)
self.assertTrue(os.path.exists(path))
- def test_referencia_inexistente(self):
+ def test_missing_reference(self):
simple_tree(self.root)
memory_tree(self.root)
code, _, err = self.run_cli("-m", "-s", "no-existe-nada")
self.assertEqual(code, 2)
self.assertIn("ninguna memoria", err)
- def test_html_embebe_las_memorias(self):
+ def test_html_embeds_the_memories(self):
simple_tree(self.root)
memory_tree(self.root)
out_path = os.path.join(self.home, "s.html")
diff --git a/tests/test_memory.py b/tests/test_memory.py
index 6491c9b..460d4ec 100644
--- a/tests/test_memory.py
+++ b/tests/test_memory.py
@@ -10,7 +10,7 @@ from .fixtures import (
class MemoryCase(unittest.TestCase):
- """Cada test corre contra un ~/.claude/projects de mentira."""
+ """Each test runs against a fake ~/.claude/projects."""
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
@@ -18,14 +18,14 @@ class MemoryCase(unittest.TestCase):
self.root = os.path.join(self._tmp.name, "projects")
os.makedirs(self.root)
- def cargar(self):
- """Sesiones + memorias del árbol, como las ve la CLI."""
+ def load_items(self):
+ """Sessions + memories of the tree, as the CLI sees them."""
ss = sessions.load_sessions(root=self.root, use_cache=False)
return ss, memory.load_memories(ss, root=self.root)
-class TestParseo(MemoryCase):
- def test_lee_frontmatter_y_cuerpo(self):
+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",
origin="abc123")
@@ -36,14 +36,14 @@ class TestParseo(MemoryCase):
self.assertEqual(m["src"], "abc123")
self.assertEqual(m["body"], "el cuerpo")
- def test_descripcion_entrecomillada_pierde_los_escapes(self):
- # Claude escribe la descripción como string YAML cuando trae comillas.
+ 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"')
self.assertEqual(memory.read_memory(path, "-home-u-proj")["desc"],
'la máquina "legion" y algo')
- def test_sin_frontmatter_cae_al_nombre_del_archivo(self):
+ 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)
m = memory.read_memory(path, "-home-u-proj")
@@ -51,78 +51,78 @@ class TestParseo(MemoryCase):
self.assertEqual(m["ty"], "—")
self.assertEqual(m["body"], "solo texto")
- def test_junta_los_enlaces_sin_repetir(self):
+ def test_collects_links_without_repeats(self):
path = write_memory(self.root, "-home-u-proj", "l",
body="[[uno]] y [[dos]] y otra vez [[uno]]")
self.assertEqual(memory.read_memory(path, "-home-u-proj")["ln"],
["dos", "uno"])
-class TestCarga(MemoryCase):
- def test_resuelve_la_ruta_del_proyecto_desde_las_sesiones(self):
+class TestLoading(MemoryCase):
+ def test_resolves_the_project_path_from_the_sessions(self):
simple_tree(self.root)
memory_tree(self.root)
- _, mems = self.cargar()
+ _, mems = self.load_items()
deploy = next(m for m in mems if m["name"] == "deploy-docker")
self.assertEqual(deploy["p"], "/home/u/proj")
- def test_sin_sesiones_deja_el_nombre_codificado(self):
- # No se puede invertir: "/" y "." se codifican los dos como "-".
+ def test_no_sessions_keeps_the_encoded_name(self):
+ # It cannot be reversed: "/" and "." are both encoded as "-".
memory_tree(self.root)
- _, mems = self.cargar()
+ _, mems = self.load_items()
self.assertEqual(
next(m for m in mems if m["name"] == "deploy-docker")["p"],
"-home-u-proj")
- def test_ignora_los_directorios_memory_vacios(self):
+ def test_ignores_empty_memory_directories(self):
memory_tree(self.root)
- _, mems = self.cargar()
+ _, mems = self.load_items()
self.assertNotIn("-home-u-vacio", {m["project_dir"] for m in mems})
- def test_marca_lo_que_esta_en_el_indice(self):
+ def test_marks_what_is_in_the_index(self):
memory_tree(self.root)
- _, mems = self.cargar()
- por_nombre = {m["name"]: m for m in mems}
- self.assertTrue(por_nombre["deploy-docker"]["ix"])
- self.assertFalse(por_nombre["suelta"]["ix"])
- self.assertTrue(por_nombre["suelta"]["hix"])
- self.assertFalse(por_nombre["sin-indice"]["hix"])
-
- def test_ordena_por_fecha_descendente(self):
+ _, 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"])
+
+ def test_sorts_by_date_descending(self):
memory_tree(self.root)
- _, mems = self.cargar()
- fechas = [m["l"] for m in mems]
- self.assertEqual(fechas, sorted(fechas, reverse=True))
+ _, mems = self.load_items()
+ dates = [m["l"] for m in mems]
+ self.assertEqual(dates, sorted(dates, reverse=True))
- def test_public_records_saca_las_claves_internas(self):
+ def test_public_records_drops_internal_keys(self):
memory_tree(self.root)
- _, mems = self.cargar()
+ _, mems = self.load_items()
for m in memory.public_records(mems):
self.assertNotIn("project_dir", m)
- # El original no se toca.
+ # The original is left untouched.
self.assertIn("project_dir", mems[0])
-class TestFiltros(MemoryCase):
+class TestFilters(MemoryCase):
def setUp(self):
super().setUp()
simple_tree(self.root)
memory_tree(self.root)
- _, self.mems = self.cargar()
+ _, self.mems = self.load_items()
- def test_por_tipo(self):
+ def test_by_type(self):
r = memory.apply_filters(self.mems, kind="reference")
self.assertEqual([m["name"] for m in r], ["roles-db"])
- def test_por_proyecto(self):
+ 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])
- def test_la_query_entra_al_cuerpo(self):
+ 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_la_query_tambien_mira_la_descripcion(self):
+ 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"])
@@ -131,98 +131,98 @@ class TestPick(MemoryCase):
def setUp(self):
super().setUp()
memory_tree(self.root)
- _, self.mems = self.cargar()
+ _, self.mems = self.load_items()
- def test_por_indice(self):
+ def test_by_index(self):
self.assertEqual(memory.pick(self.mems, "1"), self.mems[0])
- def test_indice_fuera_de_rango(self):
+ def test_index_out_of_range(self):
with self.assertRaises(sessions.SessionError):
memory.pick(self.mems, "99")
- def test_por_prefijo(self):
+ def test_by_prefix(self):
self.assertEqual(memory.pick(self.mems, "deploy")["name"], "deploy-docker")
- def test_cae_a_subcadena(self):
+ def test_falls_back_to_substring(self):
self.assertEqual(memory.pick(self.mems, "docker")["name"], "deploy-docker")
def test_sin_coincidencias(self):
with self.assertRaises(sessions.SessionError):
memory.pick(self.mems, "nada-que-ver")
- def test_ambiguo(self):
+ def test_ambiguous(self):
write_memory(self.root, "-home-u-proj", "deploy-otro")
- _, mems = self.cargar()
+ _, mems = self.load_items()
with self.assertRaises(sessions.SessionError) as ctx:
memory.pick(mems, "deploy")
self.assertIn("ambiguo", str(ctx.exception))
-class TestAuditoria(MemoryCase):
+class TestAudit(MemoryCase):
def setUp(self):
super().setUp()
simple_tree(self.root)
memory_tree(self.root)
- self.ss, self.mems = self.cargar()
+ self.ss, self.mems = self.load_items()
self.report = memory.audit(self.mems, self.ss, root=self.root)
- def test_proyecto_sin_indice(self):
+ def test_project_without_index(self):
self.assertEqual([m["name"] for m in self.report["sin_indice"]],
["sin-indice"])
- def test_memoria_fuera_del_indice(self):
+ def test_memory_outside_the_index(self):
self.assertEqual([m["name"] for m in self.report["sin_listar"]],
["suelta"])
- def test_entrada_del_indice_sin_archivo(self):
+ def test_index_entry_without_file(self):
self.assertEqual([n for _, n in self.report["indice_fantasma"]],
["borrada-hace-rato"])
- def test_enlace_roto(self):
- rotos = [link for _, link in self.report["enlaces_rotos"]]
- self.assertEqual(rotos, ["no-existe"]) # [[roles-db]] sí resuelve
+ def test_broken_link(self):
+ broken = [link for _, link in self.report["enlaces_rotos"]]
+ self.assertEqual(broken, ["no-existe"]) # [[roles-db]] does resolve
- def test_sesion_de_origen_perdida(self):
- # deploy-docker apunta a una sesión que existe; sin-indice no.
+ 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"])
- def test_arbol_consistente_no_reporta_nada(self):
- limpio = os.path.join(self._tmp.name, "limpio")
- os.makedirs(limpio)
- write_memory(limpio, "-p", "sola", body="sin enlaces")
- write_index(limpio, "-p", ["sola"])
- mems = memory.load_memories([], root=limpio)
- self.assertEqual(memory.audit_total(memory.audit(mems, [], root=limpio)), 0)
+ def test_consistent_tree_reports_nothing(self):
+ is_clean = os.path.join(self._tmp.name, "limpio")
+ os.makedirs(is_clean)
+ write_memory(is_clean, "-p", "sola", body="sin enlaces")
+ write_index(is_clean, "-p", ["sola"])
+ mems = memory.load_memories([], root=is_clean)
+ self.assertEqual(memory.audit_total(memory.audit(mems, [], root=is_clean)), 0)
-class TestBorrado(MemoryCase):
+class TestDeletion(MemoryCase):
def setUp(self):
super().setUp()
memory_tree(self.root)
- _, self.mems = self.cargar()
+ _, self.mems = self.load_items()
- def por_nombre(self, name):
+ def by_name(self, name):
return next(m for m in self.mems if m["name"] == name)
- def test_borra_el_archivo_y_lo_desindexa(self):
- m = self.por_nombre("deploy-docker")
+ def test_deletes_the_file_and_unindexes_it(self):
+ m = self.by_name("deploy-docker")
self.assertTrue(memory.delete(m, root=self.root))
self.assertFalse(os.path.exists(memory.memory_path(m, self.root)))
self.assertNotIn("deploy-docker",
memory.read_index("-home-u-proj", self.root))
- def test_desindexar_no_toca_las_otras_lineas(self):
- memory.unindex(self.por_nombre("deploy-docker"), root=self.root)
+ def test_unindexing_leaves_other_lines_alone(self):
+ memory.unindex(self.by_name("deploy-docker"), root=self.root)
self.assertIn("roles-db", memory.read_index("-home-u-proj", self.root))
- def test_borrar_una_que_no_estaba_indexada(self):
- m = self.por_nombre("suelta")
+ def test_delete_one_that_was_not_indexed(self):
+ m = self.by_name("suelta")
self.assertFalse(memory.delete(m, root=self.root))
self.assertFalse(os.path.exists(memory.memory_path(m, self.root)))
- def test_borrar_sin_memory_md(self):
- m = self.por_nombre("sin-indice")
+ def test_delete_without_memory_md(self):
+ m = self.by_name("sin-indice")
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 4c3d3a7..8ad48db 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -23,7 +23,7 @@ class TempRoot(unittest.TestCase):
class TestReadSession(TempRoot):
- def test_conversacion_basica(self):
+ 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)),
@@ -41,7 +41,7 @@ class TestReadSession(TempRoot):
self.assertEqual([m["r"] for m in rec["c"]], ["u", "a", "t"])
self.assertEqual(rec["c"][2]["x"], "Bash: make test")
- def test_el_titulo_de_claude_le_gana_al_primer_mensaje(self):
+ 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"),
@@ -51,7 +51,7 @@ class TestReadSession(TempRoot):
self.assertEqual(rec["t"], "Título final")
self.assertTrue(rec["ai"])
- def test_ignora_el_ruido_del_harness(self):
+ 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)),
@@ -65,7 +65,7 @@ class TestReadSession(TempRoot):
self.assertEqual(rec["a"], 0)
self.assertEqual(rec["c"][0]["x"], "texto real")
- def test_tolera_una_linea_cortada_a_la_mitad(self):
+ 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)),
])
@@ -74,7 +74,7 @@ class TestReadSession(TempRoot):
rec = S.read_session(path)
self.assertEqual(rec["u"], 1)
- def test_sesion_sin_mensajes(self):
+ def test_session_without_messages(self):
path = write_session(self.root, "-p", "55555555-0000-0000-0000-000000000000", [
{"type": "system", "timestamp": ts(0), "cwd": "/home/u/proj"},
])
@@ -83,14 +83,14 @@ class TestReadSession(TempRoot):
self.assertIsNone(rec["t"])
self.assertEqual(rec["c"], [])
- def test_un_solo_mensaje_enorme_es_claude_p(self):
+ def test_single_huge_message_is_claude_p(self):
largo = "x" * (S.NONINTERACTIVE_CHARS + 1)
path = write_session(self.root, "-p", "66666666-0000-0000-0000-000000000000", [
user(largo, at=ts(0)),
])
self.assertTrue(S.read_session(path)["n"])
- def test_una_charla_corta_no_es_claude_p(self):
+ 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)),
])
@@ -98,42 +98,42 @@ class TestReadSession(TempRoot):
class TestToolSummary(unittest.TestCase):
- def test_usa_el_parametro_representativo(self):
+ def test_uses_the_representative_parameter(self):
self.assertEqual(
S.tool_summary({"name": "Read", "input": {"file_path": "/a/b.py", "limit": 5}}),
"Read: /a/b.py")
- def test_cae_al_primer_string_si_la_tool_es_desconocida(self):
+ 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")
- def test_recorta_los_argumentos_largos(self):
+ def test_truncates_long_arguments(self):
out = S.tool_summary({"name": "Bash", "input": {"command": "a" * 500}})
self.assertTrue(out.endswith("…"))
self.assertEqual(len(out), len("Bash: ") + S.TOOL_ARG_MAX + 1)
- def test_sin_argumentos_usables(self):
+ 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")
class TestLoad(TempRoot):
- def test_ordena_por_ultima_actividad(self):
+ def test_sorts_by_last_activity(self):
simple_tree(self.root)
got = [s["id"][:8] for s in self.load()]
self.assertEqual(got, ["aaaaaaaa", "bbbbbbbb", "cccccccc"])
- def test_deduce_la_ruta_de_otra_sesion_del_proyecto(self):
+ 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))])
write_session(self.root, "-home-u-proj", "dddddddd-0000-0000-0000-000000000004",
[{"type": "system", "timestamp": ts(30)}])
- huerfana = next(s for s in self.load() if s["id"].startswith("dddddddd"))
- self.assertEqual(huerfana["p"], "/home/u/proj")
- self.assertTrue(huerfana["i"])
+ orphan = next(s for s in self.load() if s["id"].startswith("dddddddd"))
+ self.assertEqual(orphan["p"], "/home/u/proj")
+ self.assertTrue(orphan["i"])
- def test_sin_ninguna_ruta_conocida_queda_el_nombre_del_directorio(self):
+ def test_no_known_path_keeps_the_directory_name(self):
write_session(self.root, "-sin-cwd", "eeeeeeee-0000-0000-0000-000000000005",
[{"type": "system", "timestamp": ts(0)}])
s = self.load()[0]
@@ -150,12 +150,12 @@ class TestLoad(TempRoot):
class TestCache(TempRoot):
- def test_reusa_lo_que_no_cambio(self):
+ def test_reuses_what_did_not_change(self):
simple_tree(self.root)
self.load()
- # Ensuciamos el caché a mano: si la segunda corrida devuelve el título
- # falso es porque no volvió a leer el archivo.
+ # Dirty the cache by hand: if the second run returns the fake
+ # title, it did not read the file again.
with open(self.cache, encoding="utf-8") as f:
blob = json.load(f)
for entry in blob["entries"].values():
@@ -165,7 +165,7 @@ class TestCache(TempRoot):
self.assertEqual(self.load()[0]["t"], "vino del caché")
- def test_reparsea_si_el_archivo_cambio(self):
+ 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()
@@ -174,7 +174,7 @@ class TestCache(TempRoot):
self.assertEqual(self.load()[0]["u"], 2)
self.assertTrue(os.path.exists(path))
- def test_un_cache_de_otra_version_se_descarta(self):
+ def test_cache_from_another_version_is_discarded(self):
simple_tree(self.root)
self.load()
with open(self.cache, encoding="utf-8") as f:
@@ -187,18 +187,18 @@ class TestCache(TempRoot):
self.assertEqual(self.load()[0]["t"], "Arreglar el build")
- def test_un_cache_roto_no_rompe_nada(self):
+ 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")
self.assertEqual(len(self.load()), 3)
- def test_no_cache_no_escribe_nada(self):
+ def test_no_cache_writes_nothing(self):
simple_tree(self.root)
self.load(use_cache=False)
self.assertFalse(os.path.exists(self.cache))
- def test_el_cache_guarda_la_ruta_sin_deducir(self):
+ def test_cache_stores_the_path_without_inferring(self):
write_session(self.root, "-home-u-proj", "aaaaaaaa-0000-0000-0000-000000000001",