From b56d3bcfc32ce698f47d2b43e1ba8a9e07544cd0 Mon Sep 17 00:00:00 2001 From: GSN Date: Fri, 25 Sep 2026 23:39:50 -0300 Subject: [PATCH] test: pin _cut - one line for a short field, its own lines for a body lookups._cut trims every read's text before the assistant sees it and had no test of its own. CutTests pins what it does: whitespace and newlines collapse below 600, a body keeps its lines at 600, a string exactly n long is not cut, a longer one ends with ' [...]', and None reads as ''. No behaviour change - the guard is the point (issue #73). --- tests/test_lookups.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_lookups.py b/tests/test_lookups.py index d87120ee..0507a19c 100644 --- a/tests/test_lookups.py +++ b/tests/test_lookups.py @@ -16,6 +16,32 @@ def world(): def read(s, kind, **p): return concierge.read_op(s, kind, p) +class CutTests(unittest.TestCase): + """`_cut` trims every look-up's text: a short field reads as one line, a body keeps its own.""" + + def test_a_short_field_collapses_whitespace_and_newlines_to_single_spaces(self): + self.assertEqual(lookups._cut('a b\n\nc\td ', 120), 'a b c d') + + def test_a_body_keeps_its_own_lines(self): + self.assertEqual(lookups._cut('one\ntwo\n\nthree', 600), 'one\ntwo\n\nthree') + + def test_the_collapse_turns_off_at_six_hundred(self): + self.assertEqual(lookups._cut('a\nb', 599), 'a b') + self.assertEqual(lookups._cut('a\nb', 600), 'a\nb') + + def test_a_string_exactly_the_limit_is_not_cut(self): + self.assertEqual(lookups._cut('x' * 50, 50), 'x' * 50) + + def test_a_longer_string_ends_with_the_marker(self): + out = lookups._cut('y' * 80, 50) + self.assertEqual(out, 'y' * 50 + ' […]') + self.assertTrue(out.endswith(' […]')) + + def test_none_reads_as_empty(self): + self.assertEqual(lookups._cut(None, 120), '') + self.assertEqual(lookups._cut(None, 600), '') + + class LookupTests(unittest.TestCase): def test_every_new_read_is_offered_and_validated(self): b = toolcatalog.block() + toolcatalog.bucket_list('look') # reachable: the index, then its bucket (2026-09-25)