Mercurial > p > roundup > code
comparison test/db_test_base.py @ 2604:b3ea6bad36b7 maint-0.7
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 20 Jul 2004 23:27:02 +0000 |
| parents | 5455dd2ec6d7 |
| children | 572746c94537 |
comparison
equal
deleted
inserted
replaced
| 2599:3fefdbfa6141 | 2604:b3ea6bad36b7 |
|---|---|
| 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.27.2.9 2004-07-03 23:08:44 richard Exp $ | 18 # $Id: db_test_base.py,v 1.27.2.10 2004-07-20 23:27:02 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 |
| 689 f1 = self.db.file.create(content='hello') | 689 f1 = self.db.file.create(content='hello') |
| 690 f2 = self.db.file.create(content='hello, world') | 690 f2 = self.db.file.create(content='hello, world') |
| 691 i1 = self.db.issue.create(files=[f1, f2]) | 691 i1 = self.db.issue.create(files=[f1, f2]) |
| 692 self.db.commit() | 692 self.db.commit() |
| 693 d = self.db.indexer.search(['hello'], self.db.issue) | 693 d = self.db.indexer.search(['hello'], self.db.issue) |
| 694 self.assert_(d.has_key(i1)) | |
| 694 d[i1]['files'].sort() | 695 d[i1]['files'].sort() |
| 695 self.assertEquals(d, {i1: {'files': [f1, f2]}}) | 696 self.assertEquals(d, {i1: {'files': [f1, f2]}}) |
| 696 self.assertEquals(self.db.indexer.search(['world'], self.db.issue), | 697 self.assertEquals(self.db.indexer.search(['world'], self.db.issue), |
| 697 {i1: {'files': [f2]}}) | 698 {i1: {'files': [f2]}}) |
| 698 self.db.file.set(f1, content="world") | 699 self.db.file.set(f1, content="world") |
| 834 self.db.user.create(**user) | 835 self.db.user.create(**user) |
| 835 iss = self.db.issue | 836 iss = self.db.issue |
| 836 for issue in ( | 837 for issue in ( |
| 837 {'title': 'issue one', 'status': '2', 'assignedto': '1', | 838 {'title': 'issue one', 'status': '2', 'assignedto': '1', |
| 838 'foo': date.Interval('1:10'), 'priority': '3', | 839 'foo': date.Interval('1:10'), 'priority': '3', |
| 839 'deadline': date.Date('2003-01-01.00:00')}, | 840 'deadline': date.Date('2003-02-16.22:50')}, |
| 840 {'title': 'issue two', 'status': '1', 'assignedto': '2', | 841 {'title': 'issue two', 'status': '1', 'assignedto': '2', |
| 841 'foo': date.Interval('1d'), 'priority': '3', | 842 'foo': date.Interval('1d'), 'priority': '3', |
| 842 'deadline': date.Date('2003-02-16.22:50')}, | 843 'deadline': date.Date('2003-01-01.00:00')}, |
| 843 {'title': 'issue three', 'status': '1', 'priority': '2', | 844 {'title': 'issue three', 'status': '1', 'priority': '2', |
| 844 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, | 845 'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')}, |
| 845 {'title': 'non four', 'status': '3', | 846 {'title': 'non four', 'status': '3', |
| 846 'foo': date.Interval('0:10'), 'priority': '2', | 847 'foo': date.Interval('0:10'), 'priority': '2', |
| 847 'nosy': ['1'], 'deadline': date.Date('2004-03-08')}): | 848 'nosy': ['1'], 'deadline': date.Date('2004-03-08')}): |
| 848 self.db.issue.create(**issue) | 849 self.db.issue.create(**issue) |
| 891 def testFilteringMultilink(self): | 892 def testFilteringMultilink(self): |
| 892 ae, filt = self.filteringSetup() | 893 ae, filt = self.filteringSetup() |
| 893 ae(filt(None, {'nosy': '2'}, ('+','id'), (None,None)), ['3']) | 894 ae(filt(None, {'nosy': '2'}, ('+','id'), (None,None)), ['3']) |
| 894 ae(filt(None, {'nosy': '-1'}, ('+','id'), (None,None)), ['1', '2']) | 895 ae(filt(None, {'nosy': '-1'}, ('+','id'), (None,None)), ['1', '2']) |
| 895 ae(filt(None, {'nosy': ['1','2']}, ('+', 'status'), | 896 ae(filt(None, {'nosy': ['1','2']}, ('+', 'status'), |
| 896 ('-', 'activity')), ['4', '3']) | 897 ('-', 'deadline')), ['4', '3']) |
| 897 | 898 |
| 898 def testFilteringMany(self): | 899 def testFilteringMany(self): |
| 899 ae, filt = self.filteringSetup() | 900 ae, filt = self.filteringSetup() |
| 900 ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)), | 901 ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)), |
| 901 ['3']) | 902 ['3']) |
| 902 | 903 |
| 903 def testFilteringRange(self): | 904 def testFilteringRange(self): |
| 904 ae, filt = self.filteringSetup() | 905 ae, filt = self.filteringSetup() |
| 905 # Date ranges | 906 # Date ranges |
| 906 ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['2','3']) | 907 ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['1','3']) |
| 907 ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['2','3']) | 908 ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['1','3']) |
| 908 ae(filt(None, {'deadline': '; 2003-02-16'}), ['1']) | 909 ae(filt(None, {'deadline': '; 2003-02-16'}), ['2']) |
| 909 # Lets assume people won't invent a time machine, otherwise this test | 910 # Lets assume people won't invent a time machine, otherwise this test |
| 910 # may fail :) | 911 # may fail :) |
| 911 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['2', '3', '4']) | 912 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['1', '3', '4']) |
| 912 ae(filt(None, {'deadline': '2003-02-16;'}), ['2', '3', '4']) | 913 ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4']) |
| 913 # year and month granularity | 914 # year and month granularity |
| 914 ae(filt(None, {'deadline': '2002'}), []) | 915 ae(filt(None, {'deadline': '2002'}), []) |
| 915 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3']) | 916 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3']) |
| 916 ae(filt(None, {'deadline': '2004'}), ['4']) | 917 ae(filt(None, {'deadline': '2004'}), ['4']) |
| 917 ae(filt(None, {'deadline': '2003-02'}), ['2', '3']) | 918 ae(filt(None, {'deadline': '2003-02'}), ['1', '3']) |
| 918 ae(filt(None, {'deadline': '2003-03'}), []) | 919 ae(filt(None, {'deadline': '2003-03'}), []) |
| 919 ae(filt(None, {'deadline': '2003-02-16'}), ['2']) | 920 ae(filt(None, {'deadline': '2003-02-16'}), ['1']) |
| 920 ae(filt(None, {'deadline': '2003-02-17'}), []) | 921 ae(filt(None, {'deadline': '2003-02-17'}), []) |
| 921 # Interval ranges | 922 # Interval ranges |
| 922 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) | 923 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) |
| 923 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) | 924 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) |
| 924 ae(filt(None, {'foo': 'from 5:50'}), ['2']) | 925 ae(filt(None, {'foo': 'from 5:50'}), ['2']) |
| 943 ae, filt = self.filteringSetup() | 944 ae, filt = self.filteringSetup() |
| 944 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) | 945 ae(filt(None, {}, ('+','nosy'), (None,None)), ['1', '2', '4', '3']) |
| 945 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) | 946 ae(filt(None, {}, ('-','nosy'), (None,None)), ['3', '4', '1', '2']) |
| 946 | 947 |
| 947 def testFilteringDateSort(self): | 948 def testFilteringDateSort(self): |
| 948 # '1': '2003-01-01.00:00' | 949 # '1': '2003-02-16.22:50' |
| 949 # '2': '2003-02-16.22:50' | 950 # '2': '2003-01-01.00:00' |
| 950 # '3': '2003-02-18' | 951 # '3': '2003-02-18' |
| 951 # '4': '2004-03-08' | 952 # '4': '2004-03-08' |
| 952 ae, filt = self.filteringSetup() | 953 ae, filt = self.filteringSetup() |
| 953 # ascending | 954 # ascending |
| 954 ae(filt(None, {}, ('+','deadline'), (None,None)), ['1', '2', '3', '4']) | 955 ae(filt(None, {}, ('+','deadline'), (None,None)), ['2', '1', '3', '4']) |
| 955 # descending | 956 # descending |
| 956 ae(filt(None, {}, ('-','deadline'), (None,None)), ['4', '3', '2', '1']) | 957 ae(filt(None, {}, ('-','deadline'), (None,None)), ['4', '3', '1', '2']) |
| 957 | 958 |
| 958 def testFilteringDateSortPriorityGroup(self): | 959 def testFilteringDateSortPriorityGroup(self): |
| 959 # '1': '2003-01-01.00:00' 1 => 2 | 960 # '1': '2003-02-16.22:50' 1 => 2 |
| 960 # '2': '2003-02-16.22:50' 3 => 1 | 961 # '2': '2003-01-01.00:00' 3 => 1 |
| 961 # '3': '2003-02-18' 2 => 3 | 962 # '3': '2003-02-18' 2 => 3 |
| 962 # '4': '2004-03-08' 1 => 2 | 963 # '4': '2004-03-08' 1 => 2 |
| 963 ae, filt = self.filteringSetup() | 964 ae, filt = self.filteringSetup() |
| 965 | |
| 964 # ascending | 966 # ascending |
| 965 ae(filt(None, {}, ('+','deadline'), ('+','priority')), | 967 ae(filt(None, {}, ('+','deadline'), ('+','priority')), |
| 966 ['2', '1', '4', '3']) | 968 ['2', '1', '3', '4']) |
| 967 ae(filt(None, {}, ('-','deadline'), ('+','priority')), | 969 ae(filt(None, {}, ('-','deadline'), ('+','priority')), |
| 968 ['2', '4', '1', '3']) | 970 ['1', '2', '4', '3']) |
| 969 # descending | 971 # descending |
| 970 ae(filt(None, {}, ('+','deadline'), ('-','priority')), | 972 ae(filt(None, {}, ('+','deadline'), ('-','priority')), |
| 971 ['3', '1', '4', '2']) | 973 ['3', '4', '2', '1']) |
| 972 ae(filt(None, {}, ('-','deadline'), ('-','priority')), | 974 ae(filt(None, {}, ('-','deadline'), ('-','priority')), |
| 973 ['3', '4', '1', '2']) | 975 ['4', '3', '1', '2']) |
| 974 | 976 |
| 975 # XXX add sorting tests for other types | 977 # XXX add sorting tests for other types |
| 976 # XXX test auditors and reactors | 978 # XXX test auditors and reactors |
| 977 | 979 |
| 978 def testImportExport(self): | 980 def testImportExport(self): |
