comparison test/db_test_base.py @ 2418:89072e66b5f5

fixed filtering by floats in anydbm [SF#963584]
author Richard Jones <richard@users.sourceforge.net>
date Wed, 09 Jun 2004 06:35:45 +0000
parents 5fd066bcf9cf
children 0e2a0c2c8142
comparison
equal deleted inserted replaced
2416:74b63b1beff1 2418:89072e66b5f5
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.29 2004-06-08 05:35:07 richard Exp $ 18 # $Id: db_test_base.py,v 1.30 2004-06-09 06:35:45 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
811 self.db.issue.retire(ids[0]) 811 self.db.issue.retire(ids[0])
812 self.assertEqual(len(self.db.issue.stringFind(title='spam')), 1) 812 self.assertEqual(len(self.db.issue.stringFind(title='spam')), 1)
813 813
814 def filteringSetup(self): 814 def filteringSetup(self):
815 for user in ( 815 for user in (
816 {'username': 'bleep'}, 816 {'username': 'bleep', 'age': 1},
817 {'username': 'blop'}, 817 {'username': 'blop', 'age': 1.5},
818 {'username': 'blorp'}): 818 {'username': 'blorp', 'age': 2}):
819 self.db.user.create(**user) 819 self.db.user.create(**user)
820 iss = self.db.issue 820 iss = self.db.issue
821 for issue in ( 821 for issue in (
822 {'title': 'issue one', 'status': '2', 'assignedto': '1', 822 {'title': 'issue one', 'status': '2', 'assignedto': '1',
823 'foo': date.Interval('1:10'), 'priority': '1', 823 'foo': date.Interval('1:10'), 'priority': '1',
837 def testFilteringID(self): 837 def testFilteringID(self):
838 ae, filt = self.filteringSetup() 838 ae, filt = self.filteringSetup()
839 ae(filt(None, {'id': '1'}, ('+','id'), (None,None)), ['1']) 839 ae(filt(None, {'id': '1'}, ('+','id'), (None,None)), ['1'])
840 ae(filt(None, {'id': '2'}, ('+','id'), (None,None)), ['2']) 840 ae(filt(None, {'id': '2'}, ('+','id'), (None,None)), ['2'])
841 ae(filt(None, {'id': '10'}, ('+','id'), (None,None)), []) 841 ae(filt(None, {'id': '10'}, ('+','id'), (None,None)), [])
842
843 def testFilteringNumber(self):
844 self.filteringSetup()
845 ae, filt = self.assertEqual, self.db.user.filter
846 ae(filt(None, {'age': '1'}, ('+','id'), (None,None)), ['3'])
847 ae(filt(None, {'age': '1.5'}, ('+','id'), (None,None)), ['4'])
848 ae(filt(None, {'age': '2'}, ('+','id'), (None,None)), ['5'])
842 849
843 def testFilteringString(self): 850 def testFilteringString(self):
844 ae, filt = self.filteringSetup() 851 ae, filt = self.filteringSetup()
845 ae(filt(None, {'title': ['one']}, ('+','id'), (None,None)), ['1']) 852 ae(filt(None, {'title': ['one']}, ('+','id'), (None,None)), ['1'])
846 ae(filt(None, {'title': ['issue']}, ('+','id'), (None,None)), 853 ae(filt(None, {'title': ['issue']}, ('+','id'), (None,None)),

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