diff options
Diffstat (limited to 'gn2/tests/unit/wqflask/test_server_side.py')
-rw-r--r-- | gn2/tests/unit/wqflask/test_server_side.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gn2/tests/unit/wqflask/test_server_side.py b/gn2/tests/unit/wqflask/test_server_side.py new file mode 100644 index 00000000..b3e90eb9 --- /dev/null +++ b/gn2/tests/unit/wqflask/test_server_side.py @@ -0,0 +1,34 @@ +import unittest + +from gn2.wqflask.server_side import ServerSideTable + + +class TestServerSideTableTests(unittest.TestCase): + """ + Test the ServerSideTable class + + test table: + first, second, third + 'd', 4, 'zz' + 'b', 2, 'aa' + 'c', 1, 'ss' + """ + + def test_get_page(self): + rows_count = 3 + table_rows = [ + {'first': 'd', 'second': 4, 'third': 'zz'}, + {'first': 'b', 'second': 2, 'third': 'aa'}, + {'first': 'c', 'second': 1, 'third': 'ss'}, + ] + headers = ['first', 'second', 'third'] + request_args = {'sEcho': '1', 'iSortCol_0': '1', 'iSortingCols': '1', + 'sSortDir_0': 'asc', 'iDisplayStart': '0', 'iDisplayLength': '3'} + + test_page = ServerSideTable( + rows_count, table_rows, headers, request_args).get_page() + self.assertEqual(test_page['sEcho'], '1') + self.assertEqual(test_page['iTotalRecords'], 'nan') + self.assertEqual(test_page['iTotalDisplayRecords'], '3') + self.assertEqual(test_page['data'], [{'first': 'b', 'second': 2, 'third': 'aa'}, { + 'first': 'c', 'second': 1, 'third': 'ss'}, {'first': 'd', 'second': 4, 'third': 'zz'}]) |