comparison test/test_cgi.py @ 3777:74aebbbea305

Sorry for the mega-patch - was all done on the train: - handling of required for booelan False and numeric 0 [SF#1608200] - removed bogus args attr of ConfigurationError [SF#1608056] - implemented start_response in roundup.cgi [SF#1604304]
author Richard Jones <richard@users.sourceforge.net>
date Mon, 11 Dec 2006 23:36:15 +0000
parents 0119e04886d8
children 9e48fda4a41c
comparison
equal deleted inserted replaced
3776:1ac3c7ed91e8 3777:74aebbbea305
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.28 2006-08-11 00:18:59 richard Exp $ 11 # $Id: test_cgi.py,v 1.29 2006-12-11 23:36:15 richard 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
410 ({('test', nodeid): {'boolean': None}}, [])) 410 ({('test', nodeid): {'boolean': None}}, []))
411 nodeid = self.db.test.create(boolean=1) 411 nodeid = self.db.test.create(boolean=1)
412 self.assertEqual(self.parseForm({'boolean': ' '}, 'test', nodeid), 412 self.assertEqual(self.parseForm({'boolean': ' '}, 'test', nodeid),
413 ({('test', nodeid): {'boolean': None}}, [])) 413 ({('test', nodeid): {'boolean': None}}, []))
414 414
415 def testRequiredBoolean(self):
416 self.assertRaises(FormError, self.parseForm, {'boolean': '',
417 ':required': 'boolean'})
418 try:
419 self.parseForm({'boolean': 'no', ':required': 'boolean'})
420 except FormError:
421 self.fail('boolean "no" raised "required missing"')
422
415 # 423 #
416 # Number 424 # Number
417 # 425 #
418 def testEmptyNumber(self): 426 def testEmptyNumber(self):
419 self.assertEqual(self.parseForm({'number': ''}), 427 self.assertEqual(self.parseForm({'number': ''}),
457 self.assertEqual(self.parseForm({'number': ''}, 'test', nodeid), 465 self.assertEqual(self.parseForm({'number': ''}, 'test', nodeid),
458 ({('test', nodeid): {'number': None}}, [])) 466 ({('test', nodeid): {'number': None}}, []))
459 nodeid = self.db.test.create(number=1) 467 nodeid = self.db.test.create(number=1)
460 self.assertEqual(self.parseForm({'number': ' '}, 'test', nodeid), 468 self.assertEqual(self.parseForm({'number': ' '}, 'test', nodeid),
461 ({('test', nodeid): {'number': None}}, [])) 469 ({('test', nodeid): {'number': None}}, []))
470
471 def testRequiredNumber(self):
472 self.assertRaises(FormError, self.parseForm, {'number': '',
473 ':required': 'number'})
474 try:
475 self.parseForm({'number': '0', ':required': 'number'})
476 except FormError:
477 self.fail('number "no" raised "required missing"')
462 478
463 # 479 #
464 # Date 480 # Date
465 # 481 #
466 def testEmptyDate(self): 482 def testEmptyDate(self):

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