comparison test/test_db.py @ 555:5fd94347c6f2

Journal entries for link and multilink properties can now be switched on or off.
author Roche Compaan <rochecompaan@users.sourceforge.net>
date Sat, 19 Jan 2002 13:16:04 +0000
parents 22e0edf7da6e
children 62febbd7ffec
comparison
equal deleted inserted replaced
554:7e7b4183a8bd 555:5fd94347c6f2
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.14 2002-01-16 07:02:57 richard Exp $ 18 # $Id: test_db.py,v 1.15 2002-01-19 13:16:04 rochecompaan Exp $
19 19
20 import unittest, os, shutil 20 import unittest, os, shutil
21 21
22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
23 Interval, Class, DatabaseError 23 Interval, Class, DatabaseError
188 nosy=[1]) 188 nosy=[1])
189 # invalid multilink index 189 # invalid multilink index
190 ar(IndexError, self.db.issue.set, '1', title='foo', status='1', 190 ar(IndexError, self.db.issue.set, '1', title='foo', status='1',
191 nosy=['10']) 191 nosy=['10'])
192 192
193 def testJournals(self):
194 self.db.issue.addprop(fixer=Link("user", do_journal='yes'))
195 self.db.user.create(username="mary")
196 self.db.user.create(username="pete")
197 self.db.issue.create(title="spam", status='1')
198 self.db.commit()
199
200 # journal entry for issue create
201 journal = self.db.getjournal('issue', '1')
202 self.assertEqual(1, len(journal))
203 (nodeid, date_stamp, journaltag, action, params) = journal[0]
204 self.assertEqual(nodeid, '1')
205 self.assertEqual(journaltag, 'test')
206 self.assertEqual(action, 'create')
207 keys = params.keys()
208 keys.sort()
209 self.assertEqual(keys, ['deadline', 'fixer', 'foo', 'nosy',
210 'status', 'title'])
211 self.assertEqual(None,params['deadline'])
212 self.assertEqual(None,params['fixer'])
213 self.assertEqual(None,params['foo'])
214 self.assertEqual([],params['nosy'])
215 self.assertEqual('1',params['status'])
216 self.assertEqual('spam',params['title'])
217
218 # journal entry for link
219 journal = self.db.getjournal('user', '1')
220 self.assertEqual(1, len(journal))
221 self.db.issue.set('1', fixer='1')
222 self.db.commit()
223 journal = self.db.getjournal('user', '1')
224 self.assertEqual(2, len(journal))
225 (nodeid, date_stamp, journaltag, action, params) = journal[1]
226 self.assertEqual('1', nodeid)
227 self.assertEqual('test', journaltag)
228 self.assertEqual('link', action)
229 self.assertEqual(('issue', '1', 'fixer'), params)
230
231 # journal entry for unlink
232 self.db.issue.set('1', fixer='2')
233 self.db.commit()
234 journal = self.db.getjournal('user', '1')
235 self.assertEqual(3, len(journal))
236 (nodeid, date_stamp, journaltag, action, params) = journal[2]
237 self.assertEqual('1', nodeid)
238 self.assertEqual('test', journaltag)
239 self.assertEqual('unlink', action)
240 self.assertEqual(('issue', '1', 'fixer'), params)
241
193 def testRetire(self): 242 def testRetire(self):
194 pass 243 pass
195 244
196 245
197 class anydbmReadOnlyDBTestCase(MyTestCase): 246 class anydbmReadOnlyDBTestCase(MyTestCase):
283 332
284 return unittest.TestSuite(l) 333 return unittest.TestSuite(l)
285 334
286 # 335 #
287 # $Log: not supported by cvs2svn $ 336 # $Log: not supported by cvs2svn $
337 # Revision 1.14 2002/01/16 07:02:57 richard
338 # . lots of date/interval related changes:
339 # - more relaxed date format for input
340 #
288 # Revision 1.13 2002/01/14 02:20:15 richard 341 # Revision 1.13 2002/01/14 02:20:15 richard
289 # . changed all config accesses so they access either the instance or the 342 # . changed all config accesses so they access either the instance or the
290 # config attriubute on the db. This means that all config is obtained from 343 # config attriubute on the db. This means that all config is obtained from
291 # instance_config instead of the mish-mash of classes. This will make 344 # instance_config instead of the mish-mash of classes. This will make
292 # switching to a ConfigParser setup easier too, I hope. 345 # switching to a ConfigParser setup easier too, I hope.

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