Add make_engine_from_config()
method for AppHandler
and other misc. tweaks needed to get this incorporated into Rattail
This commit is contained in:
parent
afd2d005a3
commit
b458272207
8 changed files with 177 additions and 91 deletions
|
@ -117,6 +117,23 @@ baz = B
|
|||
self.assertIsNone(config.get('foo.bar'))
|
||||
self.assertEqual(config.get('foo.baz'), 'B')
|
||||
|
||||
def test_prioritized_files(self):
|
||||
first = self.write_file('first.conf', """\
|
||||
[foo]
|
||||
bar = 1
|
||||
""")
|
||||
|
||||
second = self.write_file('second.conf', """\
|
||||
[wutta.config]
|
||||
require = %(here)s/first.conf
|
||||
""")
|
||||
|
||||
config = conf.WuttaConfig(files=[second])
|
||||
files = config.get_prioritized_files()
|
||||
self.assertEqual(len(files), 2)
|
||||
self.assertEqual(files[0], second)
|
||||
self.assertEqual(files[1], first)
|
||||
|
||||
def test_constructor_defaults(self):
|
||||
config = conf.WuttaConfig()
|
||||
self.assertEqual(config.defaults, {})
|
||||
|
@ -351,6 +368,24 @@ configure_logging = true
|
|||
config = conf.WuttaConfig()
|
||||
self.assertRaises(ConfigurationError, config.require, 'foo')
|
||||
|
||||
def test_get_bool(self):
|
||||
config = conf.WuttaConfig()
|
||||
self.assertFalse(config.get_bool('foo.bar'))
|
||||
config.setdefault('foo.bar', 'true')
|
||||
self.assertTrue(config.get_bool('foo.bar'))
|
||||
|
||||
def test_get_int(self):
|
||||
config = conf.WuttaConfig()
|
||||
self.assertIsNone(config.get_int('foo.bar'))
|
||||
config.setdefault('foo.bar', '42')
|
||||
self.assertEqual(config.get_int('foo.bar'), 42)
|
||||
|
||||
def test_get_list(self):
|
||||
config = conf.WuttaConfig()
|
||||
self.assertEqual(config.get_list('foo.bar'), [])
|
||||
config.setdefault('foo.bar', 'hello world')
|
||||
self.assertEqual(config.get_list('foo.bar'), ['hello', 'world'])
|
||||
|
||||
|
||||
class TestGenericDefaultFiles(TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue