Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 603:986354c4b1fb | 604:13719594278b |
|---|---|
| 1 # $Id: test_config.py,v 1.1.2.1 2002-02-06 07:11:13 richard Exp $ | |
| 2 | |
| 3 import unittest, time, tempfile, shutil, os | |
| 4 | |
| 5 from roundup import config | |
| 6 | |
| 7 class ConfigTest(unittest.TestCase): | |
| 8 def setUp(self): | |
| 9 self.filename = tempfile.mktemp() | |
| 10 os.makedirs(self.filename) | |
| 11 open(os.path.join(self.filename, 'roundup.rc'), 'w').write(''' | |
| 12 [BASE] | |
| 13 http_port = 80 | |
| 14 database = %%(instance_home)s/db | |
| 15 templates = %%(instance_home)s/html | |
| 16 log = %%(instance_home)s/log | |
| 17 filter_position = bottom | |
| 18 anonymous_access = deny | |
| 19 anonymous_register = deny | |
| 20 messages_to_author = no | |
| 21 email_signature_position = bottom | |
| 22 | |
| 23 [%s] | |
| 24 | |
| 25 '''%self.filename) | |
| 26 open(os.path.join(self.filename, 'config.rc'), 'w').write(''' | |
| 27 [DEFAULT] | |
| 28 instance_name=My Test Instance | |
| 29 mailhost=mail.host | |
| 30 mail_domain=blah.dot.com | |
| 31 issue_tracker_email=rjones@%(mail_domain)s | |
| 32 issue_tracker_web=http://localhost:8080/ | |
| 33 admin_email=rjones@ekit-inc.com | |
| 34 | |
| 35 [MAIL GATEWAY] | |
| 36 | |
| 37 [HTTP SERVER] | |
| 38 http_port = 8080 | |
| 39 | |
| 40 [CGI] | |
| 41 | |
| 42 [ADMIN] | |
| 43 ''') | |
| 44 | |
| 45 def tearDown(self): | |
| 46 shutil.rmtree(self.filename) | |
| 47 | |
| 48 def testVars(self): | |
| 49 os.environ['ROUNDUP_CONF'] = os.path.join(self.filename, 'roundup.rc') | |
| 50 cfg = config.loadBaseConfig() | |
| 51 home, = cfg.listInstances() | |
| 52 inst = cfg.loadInstanceConfig(home) | |
| 53 self.assertEquals(inst.sections(), ['MAIL GATEWAY', | |
| 54 'ADMIN', 'HTTP SERVER', 'CGI']) | |
| 55 for section in inst.sections(): | |
| 56 self.assertEquals(inst.options(section), ['admin_email', | |
| 57 'email_signature_position', 'anonymous_register', | |
| 58 'instance_home', 'filter_position', 'issue_tracker_web', | |
| 59 'instance_name', 'database', 'mailhost', 'templates', | |
| 60 'mail_domain', 'issue_tracker_email', 'log', | |
| 61 'messages_to_author', 'http_port', 'anonymous_access']) | |
| 62 self.assertEquals(inst.getint('HTTP SERVER', 'http_port'), 8080) | |
| 63 self.assertEquals(inst.getint('CGI', 'http_port'), 80) | |
| 64 | |
| 65 def suite(): | |
| 66 return unittest.makeSuite(ConfigTest, 'test') | |
| 67 | |
| 68 | |
| 69 # | |
| 70 # $Log: not supported by cvs2svn $ | |
| 71 # | |
| 72 # vim: set filetype=python ts=4 sw=4 et si |
