Changeset 5585
- Timestamp:
- 10/22/08 23:16:43 (3 months ago)
- Files:
-
- trunk/tg/tests/base.py (modified) (2 diffs)
- trunk/tg/tests/test_stack/config/controllers/templates (deleted)
- trunk/tg/tests/test_stack/test_config.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tg/tests/base.py
r5526 r5585 14 14 from paste import httpexceptions 15 15 16 import tg 16 17 from tg import tmpl_context 17 18 from tg.util import Bunch … … 112 113 self.environ['pylons.routes_dict'].update(kargs) 113 114 return self.app.post(url, extra_environ=self.environ, params=kargs) 114 115 116 class TestConfig(AppConfig): 117 118 def __init__(self, folder, values=None): 119 120 #First we setup some base values that we know will work 121 self.renderers = ['genshi'] 122 self.render_functions = tg.util.Bunch() 123 self.package = tg.tests.test_stack 124 self.default_renderer = 'genshi' 125 self.globals = self 126 self.helpers = {} 127 self.auth_backend = None 128 self.auto_reload_templates = False 129 self.use_legacy_renderer = True 130 self.serve_static = False 131 132 #Then we overide those values with what was passed in 133 for key, value in values.items(): 134 setattr(self, key, value) 135 136 137 root = "." 138 test_base_path = os.path.join(root,'tg', 'tests', 'test_stack',) 139 test_config_path = os.path.join(test_base_path, folder) 140 print test_config_path 141 self.paths=tg.util.Bunch( 142 root=test_base_path, 143 controllers=os.path.join(test_config_path, 'controllers'), 144 static_files=os.path.join(test_config_path, 'public'), 145 templates=[os.path.join(test_config_path, 'templates')] 146 ) 147 148 def setup_helpers_and_globals(self): 149 tg.config['pylons.app_globals'] = self.globals 150 tg.config['pylons.h'] = self.helpers trunk/tg/tests/test_stack/test_config.py
r5584 r5585 1 1 import os 2 import tg 3 4 from tg.configuration import AppConfig 2 from tg.tests.base import TestConfig 5 3 from paste.fixture import TestApp 6 4 7 class TestConfig(AppConfig):8 9 def __init__(self, values=None):10 11 if not values:12 self.renderers = ['genshi']13 self.render_functions = tg.util.Bunch()14 self.package = tg.tests.test_stack15 self.default_renderer = 'genshi'16 self.globals = self17 self.helpers = {}18 self.auth_backend = None19 self.auto_reload_templates = False20 self.use_legacy_renderer = True21 self.serve_static = False22 23 else:24 for key, value in values.items():25 setattr(self, key, value)26 27 root = "."28 test_base_path = os.path.join(root,'tg', 'tests', 'test_stack',)29 test_config_path = os.path.join(test_base_path, 'config')30 print test_config_path31 self.paths=tg.util.Bunch(32 root=test_base_path,33 controllers=os.path.join(test_config_path, 'controllers'),34 static_files=os.path.join(test_config_path, 'public'),35 templates=[os.path.join(test_config_path, 'templates')]36 )37 38 def setup_helpers_and_globals(self):39 tg.config['pylons.app_globals'] = self.globals40 tg.config['pylons.h'] = self.helpers41 42 5 def setup_noDB(): 43 6 global_config = {'debug': 'true', … … 45 8 'smtp_server': 'localhost'} 46 9 47 base_config = TestConfig() 48 base_config.use_sqlalchemy = False 10 base_config = TestConfig(folder = 'config', 11 values = {'use_sqlalchemy': False} 12 ) 13 49 14 env_loader = base_config.make_load_environment() 50 15 app_maker = base_config.setup_tg_wsgi_app(env_loader) … … 53 18 54 19 def test_basic_stack(): 20 """Ensure that the tg stack returns a string""" 55 21 app = setup_noDB() 56 22 resp = app.get('/') … … 58 24 59 25 def test_config_reading(): 26 """Ensure that the config object can be read via dict and attr access""" 60 27 app = setup_noDB() 61 28 resp = app.get('/config_test') … … 67 34 68 35 def test_config_writing(): 36 """Ensure that new values can be added to the config object""" 69 37 app = setup_noDB() 70 38 value = "gooberblue" … … 73 41 resp = app.get('/config_dict_set/'+value) 74 42 assert value in resp.body 75 76 77 78 43 79 80 81 82 83