diff options
author | 2019-10-14 13:35:35 +0200 | |
---|---|---|
committer | 2019-10-14 13:35:35 +0200 | |
commit | 699b7df85e0dfc839d644f8d2ddfbb06596299b5 (patch) | |
tree | a2078f6ac6c3caac8f475dbcd3e29cbc06ffb338 | |
parent | Move sync tests to tests.bot.cogs.sync (diff) | |
parent | Move test_pagination to tests.bot subdir (diff) |
Merge branch 'pagination-tests-to-unittest' into unittest-migration
-rw-r--r-- | tests/bot/test_pagination.py | 36 |
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] |