aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bot
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-10-14 13:34:47 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-10-14 13:34:47 +0200
commit2e18b4164c70e8f96750667bfd8e0e14f4a65cff (patch)
tree15bea7b5563fff62c5c93ee13cd474de9f69cb4e /tests/bot
parentMove `tests.test_pagination` to `unittest`. (diff)
Move test_pagination to tests.bot subdir
Diffstat (limited to 'tests/bot')
-rw-r--r--tests/bot/test_pagination.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/bot/test_pagination.py b/tests/bot/test_pagination.py
new file mode 100644
index 000000000..0a734b505
--- /dev/null
+++ b/tests/bot/test_pagination.py
@@ -0,0 +1,36 @@
+from unittest import TestCase
+
+from bot import pagination
+
+
+class LinePaginatorTests(TestCase):
+ """Tests functionality of the `LinePaginator`."""
+
+ def setUp(self):
+ """Create a paginator for the test method."""
+ self.paginator = pagination.LinePaginator(prefix='', suffix='', max_size=30)
+
+ def test_add_line_raises_on_too_long_lines(self):
+ """`add_line` should raise a `RuntimeError` for too long lines."""
+ message = f"Line exceeds maximum page size {self.paginator.max_size - 2}"
+ with self.assertRaises(RuntimeError, msg=message):
+ self.paginator.add_line('x' * self.paginator.max_size)
+
+ def test_add_line_works_on_small_lines(self):
+ """`add_line` should allow small lines to be added."""
+ self.paginator.add_line('x' * (self.paginator.max_size - 3))
+
+
+class ImagePaginatorTests(TestCase):
+ """Tests functionality of the `ImagePaginator`."""
+
+ def setUp(self):
+ """Create a paginator for the test method."""
+ self.paginator = pagination.ImagePaginator()
+
+ def test_add_image_appends_image(self):
+ """`add_image` appends the image to the image list."""
+ image = 'lemon'
+ self.paginator.add_image(image)
+
+ assert self.paginator.images == [image]