'''Provide a way to configure PGWUI.
'''
+DEFAULT_HOME_ROUTE = '/'
+
def base_view(wrapped):
'''Decorator for any view which includes base.mk.
pgwui = response.get('pgwui', {})
pgwui.setdefault('url.css',
request.static_url('pgwui_common:static/pgwui.css'))
+ pgwui.setdefault('route.home',
+ request.route_url('home'))
response['pgwui'] = pgwui
return response
return wrapper
'static',
'pgwui_common:static/',
cache_max_age=3600)
+ config.add_route('home', DEFAULT_HOME_ROUTE)
pgwui_common_init.includeme(pyramid_request_config)
wrapper = pgwui_common_init.base_view(mock_view)
- response = wrapper(get_current_request())
- assert response['pgwui']['url.css'] == css_url
+ request = get_current_request()
+ response = wrapper(request)
+ pgwui = response['pgwui']
+ assert pgwui['url.css'] == css_url
+ url = (request.application_url
+ + pgwui_common_init.DEFAULT_HOME_ROUTE)
+ assert pgwui['route.home'] == url
# auth_base_view()
def __init__(self):
self.include_called = False
self.add_static_view_called = False
+ self.home_route = None
def include(self, *args):
self.include_called = True
def add_static_view(self, *args, **kwargs):
self.add_static_view_called = True
+ def add_route(self, name, route):
+ if name == 'home':
+ self.home_route = route
+
config = MockConfig()
pgwui_common_init.includeme(config)
assert config.include_called
assert config.add_static_view_called
+ assert config.home_route == '/'
# Integration tests