Changeset 5585

Show
Ignore:
Timestamp:
10/22/08 23:16:43 (3 months ago)
Author:
mramm
Message:

beginings of rendering tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tg/tests/base.py

    r5526 r5585  
    1414from paste import httpexceptions 
    1515 
     16import tg 
    1617from tg import tmpl_context 
    1718from tg.util import Bunch 
     
    112113        self.environ['pylons.routes_dict'].update(kargs) 
    113114        return self.app.post(url, extra_environ=self.environ, params=kargs) 
    114      
     115 
     116class 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  
    11import os 
    2 import tg  
    3  
    4 from tg.configuration import AppConfig 
     2from tg.tests.base import TestConfig 
    53from paste.fixture import TestApp 
    64 
    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_stack 
    15             self.default_renderer = 'genshi' 
    16             self.globals = self 
    17             self.helpers = {} 
    18             self.auth_backend = None 
    19             self.auto_reload_templates = False 
    20             self.use_legacy_renderer = True 
    21             self.serve_static = False 
    22  
    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_path 
    31         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.globals 
    40         tg.config['pylons.h'] = self.helpers 
    41          
    425def setup_noDB(): 
    436    global_config = {'debug': 'true',  
     
    458                     'smtp_server': 'localhost'} 
    469     
    47     base_config = TestConfig() 
    48     base_config.use_sqlalchemy = False 
     10    base_config = TestConfig(folder = 'config',  
     11                             values = {'use_sqlalchemy': False} 
     12                             ) 
     13                              
    4914    env_loader = base_config.make_load_environment() 
    5015    app_maker = base_config.setup_tg_wsgi_app(env_loader) 
     
    5318 
    5419def test_basic_stack(): 
     20    """Ensure that the tg stack returns a string""" 
    5521    app = setup_noDB() 
    5622    resp = app.get('/') 
     
    5824 
    5925def test_config_reading(): 
     26    """Ensure that the config object can be read via dict and attr access""" 
    6027    app = setup_noDB() 
    6128    resp = app.get('/config_test') 
     
    6734 
    6835def test_config_writing(): 
     36    """Ensure that new values can be added to the config object""" 
    6937    app = setup_noDB() 
    7038    value = "gooberblue" 
     
    7341    resp = app.get('/config_dict_set/'+value) 
    7442    assert value in resp.body 
    75      
    76      
    77      
    7843 
    79  
    80  
    81  
    82  
    83