Mercurial > p > roundup > code
comparison test/db_test_base.py @ 3675:f3785d646f22
Added two new tests:
- testFilteringMultilinkAndGroup tests the new bug in generated SQL with
MySQL 5.0, see
http://sf.net/tracker/?func=detail&atid=402788&aid=1541128&group_id=31577
It needs to be verified that it really catches the bug, I
have only MySQL 4.1 installed and the test runs through.
- testFilteringMultilinkSortGroup: This verifies that grouping by
something *and* sorting by a multilink will destroy the grouping-order
for the SQL implementation. This test fails for all the SQL backends.
Reason: We first let SQL sort by all the given sort attributes except
multilinks. *Then* we sort by all the multilink properties. Now if the
multilink is not the first sort attribute (not used in "group") but
the second (used in "sort") re-sorting will destroy the established
sort-order returned by the SQL query.
Note: I intend to fix this...
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Thu, 17 Aug 2006 09:32:46 +0000 |
| parents | fa7becc62534 |
| children | b9301ae1c34d |
comparison
equal
deleted
inserted
replaced
| 3674:a023442e691c | 3675:f3785d646f22 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: db_test_base.py,v 1.72 2006-07-13 13:30:39 schlatterbeck Exp $ | 18 # $Id: db_test_base.py,v 1.73 2006-08-17 09:32:46 schlatterbeck Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets | 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets |
| 21 | 21 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, DatabaseError, Boolean, Number, Node | 23 Interval, DatabaseError, Boolean, Number, Node |
| 926 {'username': 'bleep', 'age': 1}, | 926 {'username': 'bleep', 'age': 1}, |
| 927 {'username': 'blop', 'age': 1.5}, | 927 {'username': 'blop', 'age': 1.5}, |
| 928 {'username': 'blorp', 'age': 2}): | 928 {'username': 'blorp', 'age': 2}): |
| 929 self.db.user.create(**user) | 929 self.db.user.create(**user) |
| 930 iss = self.db.issue | 930 iss = self.db.issue |
| 931 file_content = ''.join([chr(i) for i in range(255)]) | |
| 932 f = self.db.file.create(content=file_content) | |
| 931 for issue in ( | 933 for issue in ( |
| 932 {'title': 'issue one', 'status': '2', 'assignedto': '1', | 934 {'title': 'issue one', 'status': '2', 'assignedto': '1', |
| 933 'foo': date.Interval('1:10'), 'priority': '3', | 935 'foo': date.Interval('1:10'), 'priority': '3', |
| 934 'deadline': date.Date('2003-02-16.22:50')}, | 936 'deadline': date.Date('2003-02-16.22:50')}, |
| 935 {'title': 'issue two', 'status': '1', 'assignedto': '2', | 937 {'title': 'issue two', 'status': '1', 'assignedto': '2', |
| 937 'deadline': date.Date('2003-01-01.00:00')}, | 939 'deadline': date.Date('2003-01-01.00:00')}, |
| 938 {'title': 'issue three', 'status': '1', 'priority': '2', | 940 {'title': 'issue three', 'status': '1', 'priority': '2', |
| 939 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, | 941 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, |
| 940 {'title': 'non four', 'status': '3', | 942 {'title': 'non four', 'status': '3', |
| 941 'foo': date.Interval('0:10'), 'priority': '2', | 943 'foo': date.Interval('0:10'), 'priority': '2', |
| 942 'nosy': ['1'], 'deadline': date.Date('2004-03-08')}): | 944 'nosy': ['1'], 'deadline': date.Date('2004-03-08'), |
| 945 'files': [f]}): | |
| 943 self.db.issue.create(**issue) | 946 self.db.issue.create(**issue) |
| 944 file_content = ''.join([chr(i) for i in range(255)]) | |
| 945 self.db.file.create(content=file_content) | |
| 946 self.db.commit() | 947 self.db.commit() |
| 947 return self.assertEqual, self.db.issue.filter | 948 return self.assertEqual, self.db.issue.filter |
| 948 | 949 |
| 949 def testFilteringID(self): | 950 def testFilteringID(self): |
| 950 ae, filt = self.filteringSetup() | 951 ae, filt = self.filteringSetup() |
| 981 ['3','4']) | 982 ['3','4']) |
| 982 ae(filt(None, {'assignedto': ['-1', None]}, ('+','id'), (None,None)), | 983 ae(filt(None, {'assignedto': ['-1', None]}, ('+','id'), (None,None)), |
| 983 ['3','4']) | 984 ['3','4']) |
| 984 ae(filt(None, {'assignedto': ['1', None]}, ('+','id'), (None,None)), | 985 ae(filt(None, {'assignedto': ['1', None]}, ('+','id'), (None,None)), |
| 985 ['1', '3','4']) | 986 ['1', '3','4']) |
| 987 | |
| 988 def testFilteringMultilinkAndGroup(self): | |
| 989 """testFilteringMultilinkAndGroup: | |
| 990 See roundup Bug 1541128: apparently grouping by something and | |
| 991 searching a Multilink failed with MySQL 5.0 | |
| 992 """ | |
| 993 ae, filt = self.filteringSetup() | |
| 994 ae(filt(None, {'files': '1'}, ('-','activity'), ('+','status')), ['4']) | |
| 986 | 995 |
| 987 def testFilteringRetired(self): | 996 def testFilteringRetired(self): |
| 988 ae, filt = self.filteringSetup() | 997 ae, filt = self.filteringSetup() |
| 989 self.db.issue.retire('2') | 998 self.db.issue.retire('2') |
| 990 ae(filt(None, {'status': '1'}, ('+','id'), (None,None)), ['3']) | 999 ae(filt(None, {'status': '1'}, ('+','id'), (None,None)), ['3']) |
| 1054 # 3: ['1','2'] | 1063 # 3: ['1','2'] |
| 1055 # 4: ['1'] | 1064 # 4: ['1'] |
| 1056 ae, filt = self.filteringSetup() | 1065 ae, filt = self.filteringSetup() |
| 1057 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) | 1066 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) |
| 1058 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) | 1067 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) |
| 1068 | |
| 1069 def testFilteringMultilinkSortGroup(self): | |
| 1070 # 1: status: 2 "in-progress" nosy: [] | |
| 1071 # 2: status: 1 "unread" nosy: [] | |
| 1072 # 3: status: 1 "unread" nosy: ['1','2'] | |
| 1073 # 4: status: 3 "testing" nosy: ['1'] | |
| 1074 ae, filt = self.filteringSetup() | |
| 1075 ae(filt(None, {}, ('+','nosy'), ('+','status')), ['1', '4', '2', '3']) | |
| 1076 ae(filt(None, {}, ('-','nosy'), ('+','status')), ['1', '4', '3', '2']) | |
| 1059 | 1077 |
| 1060 def testFilteringLinkSortGroup(self): | 1078 def testFilteringLinkSortGroup(self): |
| 1061 # 1: status: 2, priority: 3 | 1079 # 1: status: 2, priority: 3 |
| 1062 # 2: status: 1, priority: 3 | 1080 # 2: status: 1, priority: 3 |
| 1063 # 3: status: 1, priority: 2, | 1081 # 3: status: 1, priority: 2, |
