-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpaginationTests.py
31 lines (25 loc) · 1.07 KB
/
paginationTests.py
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
from typing import Type
import unittest
from pagination import Pagination
# Tests for the Pagination class
class PaginationTests(unittest.TestCase):
# Test if a default instance can be created
def test_defaul(self):
pagination = Pagination()
self.assertEqual(pagination.page_number, None, "Should be None")
self.assertEqual(pagination.page_size, 50, "Should be 50")
# Test if only the page size is set an instance can be created
def test_page_size_only(self):
pagination = Pagination(100)
self.assertEqual(pagination.page_number, None, "Should be None")
self.assertEqual(pagination.page_size, 100, "Should be 100")
# Tets for TypeError when the page size is not an int
def test_page_size_no_int(self):
with self.assertRaises((TypeError)):
Pagination("-1")
# Tets for TypeError when the page number is not an int
def test_page_number_no_int(self):
with self.assertRaises((TypeError)):
Pagination(99, "-1")
if __name__ == '__main__':
unittest.main()