def setUp(self): from wheezy.core.url import urlparts mock_path_for = Mock(return_value='welcome') self.options = {'path_for': mock_path_for} self.mock_request = Mock() self.mock_request.options = self.options self.mock_request.environ = {'route_args': {}} self.mock_request.ajax = False self.mock_request.root_path = 'my_site/' self.mock_request.urlparts = urlparts( scheme='https', netloc='python.org')
def setUp(self): from wheezy.core.url import urlparts from wheezy.web.handlers.base import BaseHandler from wheezy.web.handlers.method import handler_factory self.options = {} self.mock_request = Mock() self.mock_request.options = self.options self.mock_request.environ = {'route_args': {}} self.mock_request.method = 'GET' self.mock_request.root_path = 'my_site/' self.mock_request.urlparts = urlparts( scheme='https', netloc='python.org') self.handler = handler_factory(BaseHandler, self.mock_request) assert isinstance(self.handler, BaseHandler)
def setUp(self): from wheezy.core.url import urlparts from wheezy.web.handlers.base import RedirectRouteHandler from wheezy.web.handlers.method import handler_factory mock_path_for = Mock(return_value='welcome') self.options = {'path_for': mock_path_for} self.mock_request = Mock() self.mock_request.options = self.options self.mock_request.environ = {'route_args': {}} self.mock_request.method = 'GET' self.mock_request.root_path = 'my_site/' self.mock_request.urlparts = urlparts( scheme='https', netloc='python.org') self.handler = handler_factory( RedirectRouteHandler, self.mock_request, 'default') assert isinstance(self.handler, RedirectRouteHandler)
def setUp(self): from wheezy.core.url import urlparts from wheezy.web.handlers.base import BaseHandler from wheezy.web.handlers.method import handler_factory self.options = { 'AUTH_COOKIE': '_a', 'AUTH_COOKIE_PATH': 'members', 'AUTH_COOKIE_DOMAIN': 'python.org', 'AUTH_COOKIE_SECURE': True, 'HTTP_COOKIE_SECURE': False, 'HTTP_COOKIE_HTTPONLY': False, 'translations_manager': {'en': 'translations'} } self.mock_request = Mock() self.mock_request.options = self.options self.mock_request.environ = {'route_args': {'locale': 'en'}} self.mock_request.method = 'GET' self.mock_request.root_path = 'my_site/' self.mock_request.cookies = {} self.mock_request.urlparts = urlparts( scheme='https', netloc='python.org') self.handler = handler_factory(BaseHandler, self.mock_request) assert isinstance(self.handler, BaseHandler)
def absolute_url_for(self, name, **kwargs): parts = self.request.urlparts parts = parts.join(urlparts(path=self.path_for(name, **kwargs))) return parts.geturl()