aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests
diff options
context:
space:
mode:
authorBonfaceKilz2021-01-06 01:18:20 +0300
committerGitHub2021-01-06 01:18:20 +0300
commit509bfdfe7eae156714229a6c964270006788ac4e (patch)
treee719a96ece0cbb096cf9c21778f6fc551e1af343 /wqflask/tests
parent7474529d86fbd5e21a373a2f96bb2fffe4dea478 (diff)
parent7032f7b05deac0bbd2e868ffd3fe42dd1c97fb7d (diff)
downloadgenenetwork2-509bfdfe7eae156714229a6c964270006788ac4e.tar.gz
Merge pull request #404 from Uditgulati/snp_browser_changes
WIP: Snp browser changes
Diffstat (limited to 'wqflask/tests')
-rw-r--r--wqflask/tests/unit/wqflask/test_server_side.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/wqflask/tests/unit/wqflask/test_server_side.py b/wqflask/tests/unit/wqflask/test_server_side.py
new file mode 100644
index 00000000..4f91d8ca
--- /dev/null
+++ b/wqflask/tests/unit/wqflask/test_server_side.py
@@ -0,0 +1,31 @@
+import unittest
+
+from 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'}])