|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: db_test_base.py,v 1.50 2004-10-14 10:47:07 a1s Exp $ |
| 18 | +# $Id: db_test_base.py,v 1.51 2004-10-24 09:57:32 a1s Exp $ |
19 | 19 |
|
20 | 20 | import unittest, os, shutil, errno, imp, sys, time, pprint |
21 | 21 |
|
|
32 | 32 | config.RDBMS_USER = "rounduptest" |
33 | 33 | config.RDBMS_PASSWORD = "rounduptest" |
34 | 34 | config.logging = MockNull() |
35 | | -# MAIL_DOMAIN is required for config.save() |
36 | | -config.MAIL_DOMAIN = "localhost" |
| 35 | +# these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests |
| 36 | +config.MAIL_DOMAIN = "your.tracker.email.domain.example" |
| 37 | +config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/" |
| 38 | +# uncomment the following to have excessive debug output from test cases |
| 39 | +# FIXME: tracker logging level should be increased by -v arguments |
| 40 | +# to 'run_tests.py' script |
| 41 | +#config.LOGGING_LEVEL = "DEBUG" |
| 42 | + |
| 43 | +def setupTracker(dirname, backend="anydbm"): |
| 44 | + """Install and initialize new tracker in dirname; return tracker instance. |
| 45 | +
|
| 46 | + If the directory exists, it is wiped out before the operation. |
| 47 | +
|
| 48 | + """ |
| 49 | + global config |
| 50 | + try: |
| 51 | + shutil.rmtree(dirname) |
| 52 | + except OSError, error: |
| 53 | + if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
| 54 | + # create the instance |
| 55 | + init.install(dirname, 'templates/classic') |
| 56 | + init.write_select_db(dirname, backend) |
| 57 | + config.save(os.path.join(dirname, 'config.ini')) |
| 58 | + tracker = instance.open(dirname) |
| 59 | + if tracker.exists(): |
| 60 | + tracker.nuke() |
| 61 | + tracker.init(password.Password('sekrit')) |
| 62 | + return tracker |
37 | 63 |
|
38 | 64 | def setupSchema(db, create, module): |
39 | 65 | status = module.Class(db, "status", name=String()) |
@@ -1355,23 +1381,9 @@ def setUp(self): |
1355 | 1381 | def testCreation(self): |
1356 | 1382 | ae = self.assertEqual |
1357 | 1383 |
|
1358 | | - # create the instance |
1359 | | - init.install(self.dirname, 'templates/classic') |
1360 | | - init.write_select_db(self.dirname, self.backend) |
1361 | | - config.save(os.path.join(self.dirname, 'config.ini')) |
1362 | | - |
1363 | | - # check we can load the package |
1364 | | - tracker = instance.open(self.dirname) |
1365 | | - |
1366 | | - # if there is a database left behind |
1367 | | - # from previous test runs, nuke it |
1368 | | - if tracker.exists(): |
1369 | | - tracker.nuke() |
1370 | | - |
1371 | | - # initialize the tracker database |
1372 | | - tracker.init(password.Password('sekrit')) |
1373 | | - |
1374 | | - # and open the database |
| 1384 | + # set up and open a tracker |
| 1385 | + tracker = setupTracker(self.dirname, self.backend) |
| 1386 | + # open the database |
1375 | 1387 | db = self.db = tracker.open('test') |
1376 | 1388 |
|
1377 | 1389 | # check the basics of the schema and initial data set |
|
0 commit comments