Mercurial > p > roundup > code
view test/test_cgi.py @ 1378:5d1fe5d51c12
note on how to fix mysql tests - also indicate which tests are being run
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 14 Jan 2003 10:52:05 +0000 |
| parents | 9ddb3ab23a3f |
| children | 4ce6820c18fa |
line wrap: on
line source
# # Copyright (c) 2003 Richard Jones, rjones@ekit-inc.com # This module is free software, and you may redistribute it and/or modify # under the same terms as Python, so long as this copyright message and # disclaimer are retained in their original form. # # This module is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # $Id: test_cgi.py,v 1.1 2003-01-14 06:15:58 richard Exp $ import unittest, os, shutil, errno, sys, difflib, cgi from roundup.cgi import client from roundup import init, instance def makeForm(args): form = cgi.FieldStorage() for k,v in args.items(): if type(v) is type([]): form.list.append([cgi.MiniFieldStorage(k, x) for x in v]) else: form.list.append(cgi.MiniFieldStorage(k, v)) return form class FormTestCase(unittest.TestCase): def setUp(self): self.dirname = '_test_cgi_form' try: shutil.rmtree(self.dirname) except OSError, error: if error.errno not in (errno.ENOENT, errno.ESRCH): raise # create the instance init.install(self.dirname, 'classic', 'anydbm') init.initialise(self.dirname, 'sekrit') # check we can load the package self.instance = instance.open(self.dirname) # and open the database self.db = self.instance.open('admin') self.db.user.create(username='Chef', address='chef@bork.bork.bork', realname='Bork, Chef', roles='User') self.db.user.create(username='mary', address='mary@test', roles='User', realname='Contrary, Mary') def tearDown(self): self.db.close() try: shutil.rmtree(self.dirname) except OSError, error: if error.errno not in (errno.ENOENT, errno.ESRCH): raise def testParseNothing(self): client.parsePropsFromForm(self.db, self.db.issue, makeForm({})) def testParseNothingWithRequired(self): form = makeForm({':required': 'title'}) self.assertRaises(ValueError, client.parsePropsFromForm, self.db, self.db.issue, form) def suite(): l = [unittest.makeSuite(FormTestCase), ] return unittest.TestSuite(l) # vim: set filetype=python ts=4 sw=4 et si
