blob: 0a734b5051bb2c4970c1f01373eca0032ce4e6f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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]
|