Mercurial > p > roundup > code
comparison test/db_test_base.py @ 2603:5ccd99777869
fix metakit handling of filter on Link==None; fix some unit tests
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 20 Jul 2004 23:24:27 +0000 |
| parents | a32349bfcde4 |
| children | 6e9bd67fefa9 |
comparison
equal
deleted
inserted
replaced
| 2602:a32349bfcde4 | 2603:5ccd99777869 |
|---|---|
| 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.41 2004-07-20 22:59:53 richard Exp $ | 18 # $Id: db_test_base.py,v 1.42 2004-07-20 23:24:27 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint | 20 import unittest, os, shutil, errno, imp, sys, time, pprint |
| 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 |
| 836 self.db.user.create(**user) | 836 self.db.user.create(**user) |
| 837 iss = self.db.issue | 837 iss = self.db.issue |
| 838 for issue in ( | 838 for issue in ( |
| 839 {'title': 'issue one', 'status': '2', 'assignedto': '1', | 839 {'title': 'issue one', 'status': '2', 'assignedto': '1', |
| 840 'foo': date.Interval('1:10'), 'priority': '3', | 840 'foo': date.Interval('1:10'), 'priority': '3', |
| 841 'deadline': date.Date('2003-01-01.00:00')}, | 841 'deadline': date.Date('2003-02-16.22:50')}, |
| 842 {'title': 'issue two', 'status': '1', 'assignedto': '2', | 842 {'title': 'issue two', 'status': '1', 'assignedto': '2', |
| 843 'foo': date.Interval('1d'), 'priority': '3', | 843 'foo': date.Interval('1d'), 'priority': '3', |
| 844 'deadline': date.Date('2003-02-16.22:50')}, | 844 'deadline': date.Date('2003-01-01.00:00')}, |
| 845 {'title': 'issue three', 'status': '1', 'priority': '2', | 845 {'title': 'issue three', 'status': '1', 'priority': '2', |
| 846 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, | 846 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, |
| 847 {'title': 'non four', 'status': '3', | 847 {'title': 'non four', 'status': '3', |
| 848 'foo': date.Interval('0:10'), 'priority': '2', | 848 'foo': date.Interval('0:10'), 'priority': '2', |
| 849 'nosy': ['1'], 'deadline': date.Date('2004-03-08')}): | 849 'nosy': ['1'], 'deadline': date.Date('2004-03-08')}): |
| 903 ['3']) | 903 ['3']) |
| 904 | 904 |
| 905 def testFilteringRange(self): | 905 def testFilteringRange(self): |
| 906 ae, filt = self.filteringSetup() | 906 ae, filt = self.filteringSetup() |
| 907 # Date ranges | 907 # Date ranges |
| 908 ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['2','3']) | 908 ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['1','3']) |
| 909 ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['2','3']) | 909 ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['1','3']) |
| 910 ae(filt(None, {'deadline': '; 2003-02-16'}), ['1']) | 910 ae(filt(None, {'deadline': '; 2003-02-16'}), ['2']) |
| 911 # Lets assume people won't invent a time machine, otherwise this test | 911 # Lets assume people won't invent a time machine, otherwise this test |
| 912 # may fail :) | 912 # may fail :) |
| 913 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['2', '3', '4']) | 913 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['1', '3', '4']) |
| 914 ae(filt(None, {'deadline': '2003-02-16;'}), ['2', '3', '4']) | 914 ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4']) |
| 915 # year and month granularity | 915 # year and month granularity |
| 916 ae(filt(None, {'deadline': '2002'}), []) | 916 ae(filt(None, {'deadline': '2002'}), []) |
| 917 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3']) | 917 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3']) |
| 918 ae(filt(None, {'deadline': '2004'}), ['4']) | 918 ae(filt(None, {'deadline': '2004'}), ['4']) |
| 919 ae(filt(None, {'deadline': '2003-02'}), ['2', '3']) | 919 ae(filt(None, {'deadline': '2003-02'}), ['1', '3']) |
| 920 ae(filt(None, {'deadline': '2003-03'}), []) | 920 ae(filt(None, {'deadline': '2003-03'}), []) |
| 921 ae(filt(None, {'deadline': '2003-02-16'}), ['2']) | 921 ae(filt(None, {'deadline': '2003-02-16'}), ['1']) |
| 922 ae(filt(None, {'deadline': '2003-02-17'}), []) | 922 ae(filt(None, {'deadline': '2003-02-17'}), []) |
| 923 # Interval ranges | 923 # Interval ranges |
| 924 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) | 924 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) |
| 925 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) | 925 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) |
| 926 ae(filt(None, {'foo': 'from 5:50'}), ['2']) | 926 ae(filt(None, {'foo': 'from 5:50'}), ['2']) |
| 945 ae, filt = self.filteringSetup() | 945 ae, filt = self.filteringSetup() |
| 946 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) | 946 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) |
| 947 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) | 947 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) |
| 948 | 948 |
| 949 def testFilteringDateSort(self): | 949 def testFilteringDateSort(self): |
| 950 # '1': '2003-01-01.00:00' | 950 # '1': '2003-02-16.22:50' |
| 951 # '2': '2003-02-16.22:50' | 951 # '2': '2003-01-01.00:00' |
| 952 # '3': '2003-02-18' | 952 # '3': '2003-02-18' |
| 953 # '4': '2004-03-08' | 953 # '4': '2004-03-08' |
| 954 ae, filt = self.filteringSetup() | 954 ae, filt = self.filteringSetup() |
| 955 # ascending | 955 # ascending |
| 956 ae(filt(None, {}, ('+','deadline'), (None,None)), ['1', '2', '3', '4']) | 956 ae(filt(None, {}, ('+','deadline'), (None,None)), ['2', '1', '3', '4']) |
| 957 # descending | 957 # descending |
| 958 ae(filt(None, {}, ('-','deadline'), (None,None)), ['4', '3', '2', '1']) | 958 ae(filt(None, {}, ('-','deadline'), (None,None)), ['4', '3', '1', '2']) |
| 959 | 959 |
| 960 def testFilteringDateSortPriorityGroup(self): | 960 def testFilteringDateSortPriorityGroup(self): |
| 961 # '1': '2003-01-01.00:00' 1 => 2 | 961 # '1': '2003-02-16.22:50' 1 => 2 |
| 962 # '2': '2003-02-16.22:50' 3 => 1 | 962 # '2': '2003-01-01.00:00' 3 => 1 |
| 963 # '3': '2003-02-18' 2 => 3 | 963 # '3': '2003-02-18' 2 => 3 |
| 964 # '4': '2004-03-08' 1 => 2 | 964 # '4': '2004-03-08' 1 => 2 |
| 965 ae, filt = self.filteringSetup() | 965 ae, filt = self.filteringSetup() |
| 966 | |
| 966 # ascending | 967 # ascending |
| 967 ae(filt(None, {}, ('+','deadline'), ('+','priority')), | 968 ae(filt(None, {}, ('+','deadline'), ('+','priority')), |
| 968 ['1', '2', '3', '4']) | 969 ['2', '1', '3', '4']) |
| 969 ae(filt(None, {}, ('-','deadline'), ('+','priority')), | 970 ae(filt(None, {}, ('-','deadline'), ('+','priority')), |
| 970 ['2', '1', '4', '3']) | 971 ['1', '2', '4', '3']) |
| 971 # descending | 972 # descending |
| 972 ae(filt(None, {}, ('+','deadline'), ('-','priority')), | 973 ae(filt(None, {}, ('+','deadline'), ('-','priority')), |
| 973 ['3', '4', '1', '2']) | 974 ['3', '4', '2', '1']) |
| 974 ae(filt(None, {}, ('-','deadline'), ('-','priority')), | 975 ae(filt(None, {}, ('-','deadline'), ('-','priority')), |
| 975 ['4', '3', '2', '1']) | 976 ['4', '3', '1', '2']) |
| 976 | 977 |
| 977 # XXX add sorting tests for other types | 978 # XXX add sorting tests for other types |
| 978 # XXX test auditors and reactors | 979 # XXX test auditors and reactors |
| 979 | 980 |
| 980 def testImportExport(self): | 981 def testImportExport(self): |
