comparison test/test_cgi.py @ 2821:0f0299b2a5e8

use tracker setup function from db_test_base; remove hand-made 'config' class - unused.
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Sun, 24 Oct 2004 10:00:13 +0000
parents a5c5a1106e3b
children 7a8a02646d4e
comparison
equal deleted inserted replaced
2820:da2a9175eb83 2821:0f0299b2a5e8
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.24 2004-09-28 10:47:20 a1s Exp $ 11 # $Id: test_cgi.py,v 1.25 2004-10-24 10:00:13 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
17 from roundup.cgi.form_parser import FormParser 17 from roundup.cgi.form_parser import FormParser
18 from roundup import init, instance, password, hyperdb, date 18 from roundup import init, instance, password, hyperdb, date
19
20 import db_test_base
19 21
20 NEEDS_INSTANCE = 1 22 NEEDS_INSTANCE = 1
21 23
22 class FileUpload: 24 class FileUpload:
23 def __init__(self, content, filename): 25 def __init__(self, content, filename):
34 x.filename = v.filename 36 x.filename = v.filename
35 form.list.append(x) 37 form.list.append(x)
36 else: 38 else:
37 form.list.append(cgi.MiniFieldStorage(k, v)) 39 form.list.append(cgi.MiniFieldStorage(k, v))
38 return form 40 return form
39
40 class config:
41 TRACKER_NAME = 'testing testing'
42 TRACKER_WEB = 'http://testing.testing/'
43 41
44 cm = client.clean_message 42 cm = client.clean_message
45 class MessageTestCase(unittest.TestCase): 43 class MessageTestCase(unittest.TestCase):
46 def testCleanMessageOK(self): 44 def testCleanMessageOK(self):
47 self.assertEqual(cm('<br>x<br />'), '<br>x<br />') 45 self.assertEqual(cm('<br>x<br />'), '<br>x<br />')
62 '&lt;iframe&gt;x&lt;/iframe&gt;') 60 '&lt;iframe&gt;x&lt;/iframe&gt;')
63 61
64 class FormTestCase(unittest.TestCase): 62 class FormTestCase(unittest.TestCase):
65 def setUp(self): 63 def setUp(self):
66 self.dirname = '_test_cgi_form' 64 self.dirname = '_test_cgi_form'
67 try: 65 # set up and open a tracker
68 shutil.rmtree(self.dirname) 66 self.instance = db_test_base.setupTracker(self.dirname)
69 except OSError, error:
70 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
71 # create the instance
72 init.install(self.dirname, 'templates/classic')
73 init.write_select_db(self.dirname, 'anydbm')
74 self.instance = tracker = instance.open(self.dirname)
75 if tracker.exists():
76 tracker.nuke()
77 tracker.init(password.Password('sekrit'))
78 67
79 # open the database 68 # open the database
80 self.db = self.instance.open('admin') 69 self.db = self.instance.open('admin')
81 self.db.user.create(username='Chef', address='chef@bork.bork.bork', 70 self.db.user.create(username='Chef', address='chef@bork.bork.bork',
82 realname='Bork, Chef', roles='User') 71 realname='Bork, Chef', roles='User')

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