comparison test/test_cgi.py @ 2696:a5c5a1106e3b

init.initialize() was removed in [[CVS:1.30]] (27-jul-2004) initialize test tracker as it is done in admin.py new Tracker objects don't have 'dbinit' property. use .get_backend() to obtain class 'Class' from selected backend. trim trailing spaces; fix vim modeline
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Tue, 28 Sep 2004 10:47:20 +0000
parents 45ad02759998
children 0f0299b2a5e8
comparison
equal deleted inserted replaced
2695:c26716932ffe 2696:a5c5a1106e3b
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_cgi.py,v 1.23 2004-02-17 03:48:08 richard Exp $ 11 # $Id: test_cgi.py,v 1.24 2004-09-28 10:47:20 a1s Exp $
12 12
13 import unittest, os, shutil, errno, sys, difflib, cgi, re 13 import unittest, os, shutil, errno, sys, difflib, cgi, re
14 14
15 from roundup.cgi import client 15 from roundup.cgi import client
16 from roundup.cgi.exceptions import FormError 16 from roundup.cgi.exceptions import FormError
69 except OSError, error: 69 except OSError, error:
70 if error.errno not in (errno.ENOENT, errno.ESRCH): raise 70 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
71 # create the instance 71 # create the instance
72 init.install(self.dirname, 'templates/classic') 72 init.install(self.dirname, 'templates/classic')
73 init.write_select_db(self.dirname, 'anydbm') 73 init.write_select_db(self.dirname, 'anydbm')
74 init.initialise(self.dirname, 'sekrit') 74 self.instance = tracker = instance.open(self.dirname)
75 75 if tracker.exists():
76 # check we can load the package 76 tracker.nuke()
77 self.instance = instance.open(self.dirname) 77 tracker.init(password.Password('sekrit'))
78 # and open the database 78
79 # open the database
79 self.db = self.instance.open('admin') 80 self.db = self.instance.open('admin')
80 self.db.user.create(username='Chef', address='chef@bork.bork.bork', 81 self.db.user.create(username='Chef', address='chef@bork.bork.bork',
81 realname='Bork, Chef', roles='User') 82 realname='Bork, Chef', roles='User')
82 self.db.user.create(username='mary', address='mary@test', 83 self.db.user.create(username='mary', address='mary@test',
83 roles='User', realname='Contrary, Mary') 84 roles='User', realname='Contrary, Mary')
84 85
85 test = self.instance.dbinit.Class(self.db, "test", 86 test = self.instance.get_backend().Class(self.db, "test",
86 string=hyperdb.String(), number=hyperdb.Number(), 87 string=hyperdb.String(), number=hyperdb.Number(),
87 boolean=hyperdb.Boolean(), link=hyperdb.Link('test'), 88 boolean=hyperdb.Boolean(), link=hyperdb.Link('test'),
88 multilink=hyperdb.Multilink('test'), date=hyperdb.Date(), 89 multilink=hyperdb.Multilink('test'), date=hyperdb.Date(),
89 interval=hyperdb.Interval()) 90 interval=hyperdb.Interval())
90 91
271 form.list.append(cgi.MiniFieldStorage('nosy', '3')) 272 form.list.append(cgi.MiniFieldStorage('nosy', '3'))
272 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) 273 cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form)
273 cl.classname = 'issue' 274 cl.classname = 'issue'
274 cl.nodeid = None 275 cl.nodeid = None
275 cl.db = self.db 276 cl.db = self.db
276 self.assertEqual(cl.parsePropsFromForm(create=1), 277 self.assertEqual(cl.parsePropsFromForm(create=1),
277 ({('issue', None): {'nosy': ['1','2', '3']}}, [])) 278 ({('issue', None): {'nosy': ['1','2', '3']}}, []))
278 279
279 def testEmptyMultilinkSet(self): 280 def testEmptyMultilinkSet(self):
280 nodeid = self.db.issue.create(nosy=['1','2']) 281 nodeid = self.db.issue.create(nosy=['1','2'])
281 self.assertEqual(self.parseForm({'nosy': ''}, 'issue', nodeid), 282 self.assertEqual(self.parseForm({'nosy': ''}, 'issue', nodeid),
282 ({('issue', nodeid): {'nosy': []}}, [])) 283 ({('issue', nodeid): {'nosy': []}}, []))
283 nodeid = self.db.issue.create(nosy=['1','2']) 284 nodeid = self.db.issue.create(nosy=['1','2'])
284 self.assertEqual(self.parseForm({'nosy': ' '}, 'issue', nodeid), 285 self.assertEqual(self.parseForm({'nosy': ' '}, 'issue', nodeid),
285 ({('issue', nodeid): {'nosy': []}}, [])) 286 ({('issue', nodeid): {'nosy': []}}, []))
286 self.assertEqual(self.parseForm({'nosy': '1,2'}, 'issue', nodeid), 287 self.assertEqual(self.parseForm({'nosy': '1,2'}, 'issue', nodeid),
287 ({('issue', nodeid): {}}, [])) 288 ({('issue', nodeid): {}}, []))
288 289
289 def testInvalidMultilinkValue(self): 290 def testInvalidMultilinkValue(self):
466 467
467 def testSetDate(self): 468 def testSetDate(self):
468 self.assertEqual(self.parseForm({'date': '2003-01-01'}), 469 self.assertEqual(self.parseForm({'date': '2003-01-01'}),
469 ({('test', None): {'date': date.Date('2003-01-01')}}, [])) 470 ({('test', None): {'date': date.Date('2003-01-01')}}, []))
470 nodeid = self.db.test.create(date=date.Date('2003-01-01')) 471 nodeid = self.db.test.create(date=date.Date('2003-01-01'))
471 self.assertEqual(self.parseForm({'date': '2003-01-01'}, 'test', 472 self.assertEqual(self.parseForm({'date': '2003-01-01'}, 'test',
472 nodeid), ({('test', nodeid): {}}, [])) 473 nodeid), ({('test', nodeid): {}}, []))
473 474
474 def testEmptyDateSet(self): 475 def testEmptyDateSet(self):
475 nodeid = self.db.test.create(date=date.Date('.')) 476 nodeid = self.db.test.create(date=date.Date('.'))
476 self.assertEqual(self.parseForm({'date': ''}, 'test', nodeid), 477 self.assertEqual(self.parseForm({'date': ''}, 'test', nodeid),
477 ({('test', nodeid): {'date': None}}, [])) 478 ({('test', nodeid): {'date': None}}, []))
478 nodeid = self.db.test.create(date=date.Date('1970-01-01.00:00:00')) 479 nodeid = self.db.test.create(date=date.Date('1970-01-01.00:00:00'))
479 self.assertEqual(self.parseForm({'date': ' '}, 'test', nodeid), 480 self.assertEqual(self.parseForm({'date': ' '}, 'test', nodeid),
480 ({('test', nodeid): {'date': None}}, [])) 481 ({('test', nodeid): {'date': None}}, []))
481 482
482 # 483 #
483 # Test multiple items in form 484 # Test multiple items in form
484 # 485 #
541 542
542 if __name__ == '__main__': 543 if __name__ == '__main__':
543 runner = unittest.TextTestRunner() 544 runner = unittest.TextTestRunner()
544 unittest.main(testRunner=runner) 545 unittest.main(testRunner=runner)
545 546
546 # vim: set filetype=python ts=4 sw=4 et si 547 # vim: set filetype=python sts=4 sw=4 et si :

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