Mercurial > p > roundup > code
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test_config.py Wed Feb 06 07:11:13 2002 +0000 @@ -0,0 +1,72 @@ +# $Id: test_config.py,v 1.1.2.1 2002-02-06 07:11:13 richard Exp $ + +import unittest, time, tempfile, shutil, os + +from roundup import config + +class ConfigTest(unittest.TestCase): + def setUp(self): + self.filename = tempfile.mktemp() + os.makedirs(self.filename) + open(os.path.join(self.filename, 'roundup.rc'), 'w').write(''' +[BASE] +http_port = 80 +database = %%(instance_home)s/db +templates = %%(instance_home)s/html +log = %%(instance_home)s/log +filter_position = bottom +anonymous_access = deny +anonymous_register = deny +messages_to_author = no +email_signature_position = bottom + +[%s] + +'''%self.filename) + open(os.path.join(self.filename, 'config.rc'), 'w').write(''' +[DEFAULT] +instance_name=My Test Instance +mailhost=mail.host +mail_domain=blah.dot.com +issue_tracker_email=rjones@%(mail_domain)s +issue_tracker_web=http://localhost:8080/ +admin_email=rjones@ekit-inc.com + +[MAIL GATEWAY] + +[HTTP SERVER] +http_port = 8080 + +[CGI] + +[ADMIN] +''') + + def tearDown(self): + shutil.rmtree(self.filename) + + def testVars(self): + os.environ['ROUNDUP_CONF'] = os.path.join(self.filename, 'roundup.rc') + cfg = config.loadBaseConfig() + home, = cfg.listInstances() + inst = cfg.loadInstanceConfig(home) + self.assertEquals(inst.sections(), ['MAIL GATEWAY', + 'ADMIN', 'HTTP SERVER', 'CGI']) + for section in inst.sections(): + self.assertEquals(inst.options(section), ['admin_email', + 'email_signature_position', 'anonymous_register', + 'instance_home', 'filter_position', 'issue_tracker_web', + 'instance_name', 'database', 'mailhost', 'templates', + 'mail_domain', 'issue_tracker_email', 'log', + 'messages_to_author', 'http_port', 'anonymous_access']) + self.assertEquals(inst.getint('HTTP SERVER', 'http_port'), 8080) + self.assertEquals(inst.getint('CGI', 'http_port'), 80) + +def suite(): + return unittest.makeSuite(ConfigTest, 'test') + + +# +# $Log: not supported by cvs2svn $ +# +# vim: set filetype=python ts=4 sw=4 et si
