Mercurial > p > roundup > code
annotate test/test_config.py @ 604:13719594278b config-0-4-0-branch
I've re-worked the config structure a little so it's simpler
(one less file) and added a unit test so we can be sure it's working.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 06 Feb 2002 07:11:13 +0000 |
| parents | |
| children |
| rev | line source |
|---|---|
|
604
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 # $Id: test_config.py,v 1.1.2.1 2002-02-06 07:11:13 richard Exp $ |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 import unittest, time, tempfile, shutil, os |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 from roundup import config |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 class ConfigTest(unittest.TestCase): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 def setUp(self): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 self.filename = tempfile.mktemp() |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 os.makedirs(self.filename) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 open(os.path.join(self.filename, 'roundup.rc'), 'w').write(''' |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 [BASE] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 http_port = 80 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 database = %%(instance_home)s/db |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 templates = %%(instance_home)s/html |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 log = %%(instance_home)s/log |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 filter_position = bottom |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 anonymous_access = deny |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 anonymous_register = deny |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 messages_to_author = no |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 email_signature_position = bottom |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 [%s] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 '''%self.filename) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 open(os.path.join(self.filename, 'config.rc'), 'w').write(''' |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 [DEFAULT] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 instance_name=My Test Instance |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 mailhost=mail.host |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 mail_domain=blah.dot.com |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 issue_tracker_email=rjones@%(mail_domain)s |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 issue_tracker_web=http://localhost:8080/ |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 admin_email=rjones@ekit-inc.com |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 [MAIL GATEWAY] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 [HTTP SERVER] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 http_port = 8080 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 [CGI] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 [ADMIN] |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 ''') |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 def tearDown(self): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 shutil.rmtree(self.filename) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 def testVars(self): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 os.environ['ROUNDUP_CONF'] = os.path.join(self.filename, 'roundup.rc') |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 cfg = config.loadBaseConfig() |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 home, = cfg.listInstances() |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 inst = cfg.loadInstanceConfig(home) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 self.assertEquals(inst.sections(), ['MAIL GATEWAY', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 'ADMIN', 'HTTP SERVER', 'CGI']) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 for section in inst.sections(): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 self.assertEquals(inst.options(section), ['admin_email', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 'email_signature_position', 'anonymous_register', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 'instance_home', 'filter_position', 'issue_tracker_web', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 'instance_name', 'database', 'mailhost', 'templates', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 'mail_domain', 'issue_tracker_email', 'log', |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 'messages_to_author', 'http_port', 'anonymous_access']) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 self.assertEquals(inst.getint('HTTP SERVER', 'http_port'), 8080) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 self.assertEquals(inst.getint('CGI', 'http_port'), 80) |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 def suite(): |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 return unittest.makeSuite(ConfigTest, 'test') |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 # |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 # $Log: not supported by cvs2svn $ |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 # |
|
13719594278b
I've re-worked the config structure a little so it's simpler
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 # vim: set filetype=python ts=4 sw=4 et si |
