Skip to content

Commit 30fc0ff

Browse files
author
Alexander Smishlajev
committed
tracker setup put in separate function for use in other test suites
1 parent c019a9f commit 30fc0ff

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

test/db_test_base.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
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 $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -32,8 +32,34 @@
3232
config.RDBMS_USER = "rounduptest"
3333
config.RDBMS_PASSWORD = "rounduptest"
3434
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
3763

3864
def setupSchema(db, create, module):
3965
status = module.Class(db, "status", name=String())
@@ -1355,23 +1381,9 @@ def setUp(self):
13551381
def testCreation(self):
13561382
ae = self.assertEqual
13571383

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
13751387
db = self.db = tracker.open('test')
13761388

13771389
# check the basics of the schema and initial data set

0 commit comments

Comments
 (0)