aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-09-15 16:57:13 +0200
committerGravatar GitHub <[email protected]>2019-09-15 16:57:13 +0200
commit7292a5ab4f7b52b01c02dcb0bf73f1752237fddd (patch)
tree8e99aea5f8a5a244c5b9ab3f5d5ed5f8f2f97d3d /tests
parentMerge pull request #417 from python-discord/validate-antispam-config-in-ci (diff)
parentAdd basic tests for `bot.pagination`. (diff)
Merge pull request #423 from python-discord/bot-pagination-tests
Add basic tests for `bot.pagination`.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pagination.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_pagination.py b/tests/test_pagination.py
new file mode 100644
index 000000000..11d6541ae
--- /dev/null
+++ b/tests/test_pagination.py
@@ -0,0 +1,29 @@
+from unittest import TestCase
+
+import pytest
+
+from bot import pagination
+
+
+class LinePaginatorTests(TestCase):
+ def setUp(self):
+ self.paginator = pagination.LinePaginator(prefix='', suffix='', max_size=30)
+
+ def test_add_line_raises_on_too_long_lines(self):
+ message = f"Line exceeds maximum page size {self.paginator.max_size - 2}"
+ with pytest.raises(RuntimeError, match=message):
+ self.paginator.add_line('x' * self.paginator.max_size)
+
+ def test_add_line_works_on_small_lines(self):
+ self.paginator.add_line('x' * (self.paginator.max_size - 3))
+
+
+class ImagePaginatorTests(TestCase):
+ def setUp(self):
+ self.paginator = pagination.ImagePaginator()
+
+ def test_add_image_appends_image(self):
+ image = 'lemon'
+ self.paginator.add_image(image)
+
+ assert self.paginator.images == [image]