comparison test/test_db.py @ 887:e7169d6e6e45

added tests for number type too
author Richard Jones <richard@users.sourceforge.net>
date Thu, 18 Jul 2002 11:50:58 +0000
parents 816b593c755f
children 976316fcca66
comparison
equal deleted inserted replaced
886:816b593c755f 887:e7169d6e6e45
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: test_db.py,v 1.32 2002-07-18 11:41:10 richard Exp $ 18 # $Id: test_db.py,v 1.33 2002-07-18 11:50:58 richard Exp $
19 19
20 import unittest, os, shutil, time 20 import unittest, os, shutil, time
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 23 Interval, DatabaseError, Boolean, Number
109 a = self.db.issue.get('1', "foo") 109 a = self.db.issue.get('1', "foo")
110 self.db.issue.set('1', foo=date.Interval('-1d')) 110 self.db.issue.set('1', foo=date.Interval('-1d'))
111 self.assertNotEqual(self.db.issue.get('1', "foo"), a) 111 self.assertNotEqual(self.db.issue.get('1', "foo"), a)
112 112
113 def testBooleanChange(self): 113 def testBooleanChange(self):
114 self.db.user.create(username='foo', assignable='1') 114 self.db.user.create(username='foo', assignable=1)
115 a = self.db.user.get('1', 'assignable') 115 a = self.db.user.get('1', 'assignable')
116 self.db.user.set('1', assignable='false') 116 self.db.user.set('1', assignable='false')
117 self.assertNotEqual(self.db.user.get('1', 'assignable'), a) 117 self.assertNotEqual(self.db.user.get('1', 'assignable'), a)
118 self.db.user.set('1', assignable='FaLse') 118 self.db.user.set('1', assignable='FaLse')
119 self.db.user.set('1', assignable='nO') 119 self.db.user.set('1', assignable='nO')
120 self.db.user.set('1', assignable='0') 120 self.db.user.set('1', assignable=0)
121 self.db.user.set('1', assignable='tRuE') 121 self.db.user.set('1', assignable='tRuE')
122 self.db.user.set('1', assignable='yEs') 122 self.db.user.set('1', assignable='yEs')
123 self.db.user.set('1', assignable='1') 123 self.db.user.set('1', assignable=1)
124
125 def testNumberChange(self):
126 self.db.user.create(username='foo', age='1')
127 a = self.db.user.get('1', 'age')
128 self.db.user.set('1', age='3')
129 self.assertNotEqual(self.db.user.get('1', 'age'), a)
130 self.db.user.set('1', age='1.0')
124 131
125 def xtestNewProperty(self): 132 def xtestNewProperty(self):
126 ' make sure a new property is added ok ' 133 ' make sure a new property is added ok '
127 self.db.issue.create(title="spam", status='1') 134 self.db.issue.create(title="spam", status='1')
128 self.db.issue.addprop(fixer=Link("user")) 135 self.db.issue.addprop(fixer=Link("user"))
184 self.db.file.create(name="test", type="text/plain", content="hi") 191 self.db.file.create(name="test", type="text/plain", content="hi")
185 self.db.rollback() 192 self.db.rollback()
186 self.assertNotEqual(num_files, self.db.numfiles()) 193 self.assertNotEqual(num_files, self.db.numfiles())
187 self.assertEqual(num_files2, self.db.numfiles()) 194 self.assertEqual(num_files2, self.db.numfiles())
188 195
189 def xtestExceptions(self): 196 def testExceptions(self):
190 # this tests the exceptions that should be raised 197 # this tests the exceptions that should be raised
191 ar = self.assertRaises 198 ar = self.assertRaises
192 199
193 # 200 #
194 # class create 201 # class create
253 ar(ValueError, self.db.issue.set, '6', title='foo', status='1', 260 ar(ValueError, self.db.issue.set, '6', title='foo', status='1',
254 nosy=[1]) 261 nosy=[1])
255 # invalid multilink index 262 # invalid multilink index
256 ar(IndexError, self.db.issue.set, '6', title='foo', status='1', 263 ar(IndexError, self.db.issue.set, '6', title='foo', status='1',
257 nosy=['10']) 264 nosy=['10'])
265 # invalid number value
266 ar(TypeError, self.db.user.create, username='foo', age='a')
267 # invalid boolean value
268 ar(TypeError, self.db.user.create, username='foo', assignable='fubar')
269 self.db.user.create(username='foo')
270 # invalid number value
271 ar(TypeError, self.db.user.set, '3', username='foo', age='a')
272 # invalid boolean value
273 ar(TypeError, self.db.user.set, '3', username='foo', assignable='fubar')
258 274
259 def xtestJournals(self): 275 def xtestJournals(self):
260 self.db.issue.addprop(fixer=Link("user", do_journal='yes')) 276 self.db.issue.addprop(fixer=Link("user", do_journal='yes'))
261 self.db.user.create(username="mary") 277 self.db.user.create(username="mary")
262 self.db.user.create(username="pete") 278 self.db.user.create(username="pete")
544 560
545 return unittest.TestSuite(l) 561 return unittest.TestSuite(l)
546 562
547 # 563 #
548 # $Log: not supported by cvs2svn $ 564 # $Log: not supported by cvs2svn $
565 # Revision 1.32 2002/07/18 11:41:10 richard
566 # added tests for boolean type, and fixes to anydbm backend
567 #
549 # Revision 1.31 2002/07/14 23:17:45 richard 568 # Revision 1.31 2002/07/14 23:17:45 richard
550 # minor change to make testing easier 569 # minor change to make testing easier
551 # 570 #
552 # Revision 1.30 2002/07/14 06:06:34 richard 571 # Revision 1.30 2002/07/14 06:06:34 richard
553 # Did some old TODOs 572 # Did some old TODOs

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