add some tests for options within ini files
1 files added
2 files modified
| | |
| | | config_name = 'config:%s' % path |
| | | here_dir = os.getcwd() |
| | | |
| | | app = loadapp(config_name, name=section, relative_to=here_dir, global_conf=options) |
| | | app = loadapp( |
| | | config_name, |
| | | name=section, |
| | | relative_to=here_dir, |
| | | global_conf=options) |
| | | |
| | | return app |
| | | |
| | |
| | | path, section = _getpathsec(config_uri, name) |
| | | config_name = 'config:%s' % path |
| | | here_dir = os.getcwd() |
| | | return appconfig(config_name, name=section, relative_to=here_dir, global_conf=options) |
| | | return appconfig( |
| | | config_name, |
| | | name=section, |
| | | relative_to=here_dir, |
| | | global_conf=options) |
| | | |
| | | def setup_logging(config_uri, fileConfig=fileConfig, |
| | | configparser=configparser): |
New file |
| | |
| | | [app:myapp] |
| | | use = call:pyramid.tests.test_paster:make_dummyapp |
| | | |
| | | foo = %(bar)s |
| | |
| | | import os |
| | | import unittest |
| | | |
| | | here = os.path.dirname(__file__) |
| | | |
| | | class Test_get_app(unittest.TestCase): |
| | | def _callFUT(self, config_file, section_name, options=None, loadapp=None): |
| | | def _callFUT(self, config_file, section_name, **kw): |
| | | from pyramid.paster import get_app |
| | | return get_app( |
| | | config_file, section_name, options=options, loadapp=loadapp |
| | | ) |
| | | return get_app(config_file, section_name, **kw) |
| | | |
| | | def test_it(self): |
| | | app = DummyApp() |
| | |
| | | self.assertEqual(loadapp.kw, {'global_conf':options}) |
| | | self.assertEqual(result, app) |
| | | |
| | | def test_it_with_dummyapp_requiring_options(self): |
| | | options = {'bar': 'baz'} |
| | | app = self._callFUT( |
| | | os.path.join(here, 'fixtures', 'dummy.ini'), |
| | | 'myapp', options=options) |
| | | self.assertEqual(app.settings['foo'], 'baz') |
| | | |
| | | class Test_get_appsettings(unittest.TestCase): |
| | | def _callFUT(self, config_file, section_name, options=None, appconfig=None): |
| | | def _callFUT(self, config_file, section_name, **kw): |
| | | from pyramid.paster import get_appsettings |
| | | return get_appsettings(config_file, section_name, options, appconfig) |
| | | return get_appsettings(config_file, section_name, **kw) |
| | | |
| | | def test_it(self): |
| | | values = {'a':1} |
| | |
| | | self.assertEqual(appconfig.section_name, 'yourapp') |
| | | self.assertEqual(appconfig.relative_to, os.getcwd()) |
| | | self.assertEqual(result, values) |
| | | |
| | | def test_it_with_dummyapp_requiring_options(self): |
| | | options = {'bar': 'baz'} |
| | | result = self._callFUT( |
| | | os.path.join(here, 'fixtures', 'dummy.ini'), |
| | | 'myapp', options=options) |
| | | self.assertEqual(result['foo'], 'baz') |
| | | |
| | | class Test_setup_logging(unittest.TestCase): |
| | | def _callFUT(self, config_file): |
| | |
| | | def __init__(self): |
| | | self.registry = dummy_registry |
| | | |
| | | def make_dummyapp(global_conf, **settings): |
| | | app = DummyApp() |
| | | app.settings = settings |
| | | app.global_conf = global_conf |
| | | return app |
| | | |
| | | class DummyRequest: |
| | | application_url = 'http://example.com:5432' |
| | | script_name = '' |