Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/test_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,39 @@ def test_docs_search_finds_the_help_pages_and_the_owners_docs(self):
self.assertIn('Nothing in the help', read(s, 'docs.search', query='zzzqqq'))


class CutTests(unittest.TestCase):
def test_below_600_collapses_whitespace_and_newlines(self):
text = "first line\nsecond line\tthird line"

self.assertEqual(
lookups._cut(text, 599),
"first line second line third line",
)

def test_at_600_keeps_own_lines(self):
text = "first line\nsecond line\tthird line"

self.assertEqual(lookups._cut(text, 600), text)

def test_above_600_keeps_own_lines(self):
text = "first line\nsecond line\tthird line"

self.assertEqual(lookups._cut(text, 601), text)

def test_exactly_n_characters_is_not_cut(self):
text = "abcdefghij"

self.assertEqual(lookups._cut(text, 10), text)

def test_longer_text_ends_with_marker(self):
text = "abcdefghijk"

self.assertEqual(lookups._cut(text, 10), "abcdefghij […]")

def test_none_gives_empty_string(self):
self.assertEqual(lookups._cut(None, 100), "")


class AppAtWorkTests(unittest.TestCase):
"""What the agents are doing, what waits on a yes, the calendar, what happened, what failed."""

Expand Down