comparison test/db_test_base.py @ 3952:c68581212cf7

add some Range testing, all of which currently fails
author Richard Jones <richard@users.sourceforge.net>
date Thu, 20 Dec 2007 01:01:49 +0000
parents 1dab48842cbd
children 78dc9b275aeb
comparison
equal deleted inserted replaced
3951:53b922e0d2b7 3952:c68581212cf7
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.92 2007-10-26 06:52:26 richard Exp $ 18 # $Id: db_test_base.py,v 1.93 2007-12-20 01:01:49 richard Exp $
19 19
20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path
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
1182 ae, filt = self.filteringSetup() 1182 ae, filt = self.filteringSetup()
1183 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['1', '3', '4']) 1183 ae(filt(None, {'deadline': 'from 2003-02-16'}), ['1', '3', '4'])
1184 ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4']) 1184 ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4'])
1185 1185
1186 def testFilteringRangeYearMonthDay(self): 1186 def testFilteringRangeYearMonthDay(self):
1187 ae, filt = self.filteringSetup()
1188 ae(filt(None, {'deadline': '2002'}), []) 1187 ae(filt(None, {'deadline': '2002'}), [])
1189 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3']) 1188 ae(filt(None, {'deadline': '2003'}), ['1', '2', '3'])
1190 ae(filt(None, {'deadline': '2004'}), ['4']) 1189 ae(filt(None, {'deadline': '2004'}), ['4'])
1191 ae(filt(None, {'deadline': '2003-02'}), ['1', '3'])
1192 ae(filt(None, {'deadline': '2003-03'}), [])
1193 ae(filt(None, {'deadline': '2003-02-16'}), ['1']) 1190 ae(filt(None, {'deadline': '2003-02-16'}), ['1'])
1194 ae(filt(None, {'deadline': '2003-02-17'}), []) 1191 ae(filt(None, {'deadline': '2003-02-17'}), [])
1192
1193 def testFilteringRangeMonths(self):
1194 ae, filt = self.filteringSetup()
1195 for month in range(1, 5): #13):
1196 print 'MONTH', month
1197 for n in range(1, month+1):
1198 i = self.db.issue.create(title='%d.%d'%(month, n),
1199 deadline=date.Date('2004-%02d-%02d.00:00'%(month, n)))
1200 print 'CREATE', i, self.db.issue.get(i, 'deadline')
1201 self.db.commit()
1202
1203 for month in range(1, 13):
1204 r = filt(None, dict(deadline='2004-%02d'%month))
1205 assert len(r) == month, 'month %d != length %d'%(month, len(r))
1195 1206
1196 def testFilteringRangeInterval(self): 1207 def testFilteringRangeInterval(self):
1197 ae, filt = self.filteringSetup() 1208 ae, filt = self.filteringSetup()
1198 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1']) 1209 ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1'])
1199 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2']) 1210 ae(filt(None, {'foo': 'from 0:50 to 1d 2:00'}), ['1', '2'])

Roundup Issue Tracker: http://roundup-tracker.org/