Mercurial > p > roundup > code
comparison test/test_cgi.py @ 5094:92d33d3125a0
Validate properties specified for sorting and grouping in index
views. Original patch from martin.v.loewis via:
https://hg.python.org/tracker/roundup/rev/439bd3060df2
Applied by John Rouillard with some modification to properly
identify if the bad property is a sort or grouping property. Tests
added. Ideally we would never get bad sort/group properties but...
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 21 Jun 2016 21:45:24 -0400 |
| parents | e424987d294a |
| children | f608eeecf638 |
comparison
equal
deleted
inserted
replaced
| 5093:9954a358da18 | 5094:92d33d3125a0 |
|---|---|
| 785 cl.nodeid = nodeid | 785 cl.nodeid = nodeid |
| 786 cl.db = self.db | 786 cl.db = self.db |
| 787 cl.userid = userid | 787 cl.userid = userid |
| 788 cl.language = ('en',) | 788 cl.language = ('en',) |
| 789 cl._error_message = [] | 789 cl._error_message = [] |
| 790 cl._ok_message = [] | |
| 790 cl.template = template | 791 cl.template = template |
| 791 return cl | 792 return cl |
| 792 | 793 |
| 793 def testClassPermission(self): | 794 def testClassPermission(self): |
| 794 cl = self._make_client(dict(username='bob')) | 795 cl = self._make_client(dict(username='bob')) |
| 984 # Sorting and grouping for class Project works: | 985 # Sorting and grouping for class Project works: |
| 985 cl = self._make_client(depsort, classname='iss', nodeid=None, | 986 cl = self._make_client(depsort, classname='iss', nodeid=None, |
| 986 userid=chef, template='index') | 987 userid=chef, template='index') |
| 987 h = HTMLRequest(cl) | 988 h = HTMLRequest(cl) |
| 988 self.assertEqual([x.id for x in h.batch()],['2', '3', '1']) | 989 self.assertEqual([x.id for x in h.batch()],['2', '3', '1']) |
| 990 self.assertEqual(cl._error_message, []) # test for empty _error_message when sort is valid | |
| 991 self.assertEqual(cl._ok_message, []) # test for empty _ok_message when sort is valid | |
| 992 | |
| 993 # Test for correct _error_message for invalid sort/group properties | |
| 994 baddepsort = {'@action':'search','columns':'id','@sort':'dep'} | |
| 995 baddepgrp = {'@action':'search','columns':'id','@group':'dep'} | |
| 996 cl = self._make_client(baddepsort, classname='iss', nodeid=None, | |
| 997 userid=chef, template='index') | |
| 998 h = HTMLRequest(cl) | |
| 999 self.assertEqual(cl._error_message, ['Unknown sort property dep']) | |
| 1000 cl = self._make_client(baddepgrp, classname='iss', nodeid=None, | |
| 1001 userid=chef, template='index') | |
| 1002 h = HTMLRequest(cl) | |
| 1003 self.assertEqual(cl._error_message, ['Unknown group property dep']) | |
| 1004 | |
| 989 cl = self._make_client(depgrp, classname='iss', nodeid=None, | 1005 cl = self._make_client(depgrp, classname='iss', nodeid=None, |
| 990 userid=chef, template='index') | 1006 userid=chef, template='index') |
| 991 h = HTMLRequest(cl) | 1007 h = HTMLRequest(cl) |
| 992 self.assertEqual([x.id for x in h.batch()],['2', '3', '1']) | 1008 self.assertEqual([x.id for x in h.batch()],['2', '3', '1']) |
| 993 # Sorting and grouping for class User fails: | 1009 # Sorting and grouping for class User fails: |
