Esempio n. 1
0
	def __init__(self, *args, **kwargs):
		wsgiapp = pylons.test.pylonsapp
		config = wsgiapp.config
		self.app = PatchedTestApp(wsgiapp)
		app_globals._push_object(config['pylons.app_globals'])
		url._push_object(URLGenerator(config['routes.map'], environ))
		TestCase.__init__(self, *args, **kwargs)
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''
        TestCase.__init__(self, *args, **kwargs)

        LOG.debug("ConfigFile: %s " % config['__file__'])

        conffile = config['__file__']

        if pylons.test.pylonsapp:
            wsgiapp = pylons.test.pylonsapp
        else:
            wsgiapp = loadapp('config: %s' % config['__file__'])

        self.app = TestApp(wsgiapp)

        conf = None
        if conffile.startswith('/'):
            conf = appconfig('config:%s' % config['__file__'], relative_to=None)
        else:
            raise Exception('dont know how to load the application relatively')
         #conf = appconfig('config: %s' % config['__file__'], relative_to=rel)

        load_environment(conf.global_conf, conf.local_conf)
        self.appconf = conf

        url._push_object(URLGenerator(config['routes.map'], environ))

        self.isSelfTest = False
        if env.has_key("linotp.selfTest"):
            self.isSelfTest = True

        return
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     """ TestController init """
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 4
0
def create_request(path, environ=None):
    """Helper used in test cases to quickly setup a request obj.

    ``path``
        The path will become PATH_INFO
    ``environ``
        Additional environment

    Returns an instance of the `webob.Request` object.
    """
    # setup the environ
    if environ is None:
        environ = {}
    environ.update(default_environ)
    # create a "blank" WebOb Request object
    # using Pylon's Request which is a webob Request plus
    # some compatibility methods
    req = Request.blank(path, environ)
    # setup a Registry
    reg = environ.setdefault('paste.registry', Registry())
    reg.prepare()

    # setup pylons.request to point to our Registry
    reg.register(pylons.request, req)

    # setup tmpl context
    tmpl_context._push_object(ContextObj())
    url._push_object(URLGenerator(default_map, environ))
    return req
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     if pylons.test.pylonsapp:
         wsgiapp = pylons.test.pylonsapp
     else:
         wsgiapp = loadapp('config:%s' % config['__file__'])
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
Esempio n. 6
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''

        wsgiapp = pylons.test.pylonsapp
        self.app = webtest.TestApp(wsgiapp)
        self.session = 'justatest'

        url._push_object(URLGenerator(config['routes.map'], environ))
        unittest2.TestCase.__init__(self, *args, **kwargs)

        self.appconf = config

        self.resolvers_params = {
        'myDefRes': {
            'name'      : 'myDefRes',
            'fileName'  : '%(here)s/../data/testdata/def-passwd',
            'type'      : 'passwdresolver',
            },
        'myOtherRes' : {
            'name'      : 'myOtherRes',
            'fileName'  : '%(here)s/../data/testdata/myDom-passwd',
            'type'      : 'passwdresolver',
            }
        }
        self.resolvers = {
         'myOtherRes': 'useridresolver.PasswdIdResolver.IdResolver.myOtherRes',
         'myDefRes': 'useridresolver.PasswdIdResolver.IdResolver.myDefRes',
        }
Esempio n. 7
0
File: base.py Progetto: chiehwen/tg2
def create_request(path, environ=None):
    """Helper used in test cases to quickly setup a request obj.

    ``path``
        The path will become PATH_INFO
    ``environ``
        Additional environment

    Returns an instance of the `webob.Request` object.
    """
    # setup the environ
    if environ is None:
        environ = {}
    environ.update(default_environ)
    # create a "blank" WebOb Request object
    # using Pylon's Request which is a webob Request plus
    # some compatibility methods
    req = Request.blank(path, environ)
    # setup a Registry
    reg = environ.setdefault('paste.registry', Registry())
    reg.prepare()

    # setup pylons.request to point to our Registry
    reg.register(pylons.request, req)


    # setup tmpl context
    tmpl_context._push_object(ContextObj())
    url._push_object(URLGenerator(default_map, environ))
    return req
Esempio n. 8
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        # Decorate with an OPTIONS method
        # The webtest version in el6 does not have it
        if not hasattr(self.app, 'options'):
            setattr(self.app, 'options',
                    types.MethodType(_app_options, self.app))

        # Decorate with a post_json method
        # Same thing, version in el6 does not have it
        if not hasattr(self.app, 'post_json'):
            setattr(self.app, 'post_json',
                    types.MethodType(_app_post_json, self.app))

        # Decorate with a get_json method
        if not hasattr(self.app, 'get_json'):
            setattr(self.app, 'get_json',
                    types.MethodType(_app_get_json, self.app))

        url._push_object(URLGenerator(config['routes.map'], environ))
        TestCase.__init__(self, *args, **kwargs)

        self.pkey, self.cert = _generate_mock_cert()
Esempio n. 9
0
 def __init__(self, *args, **kwargs):
     if pylons.test.pylonsapp:
         wsgiapp = pylons.test.pylonsapp
     else:
         wsgiapp = loadapp('config:%s' % config['__file__'])
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
Esempio n. 10
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''
        TestCase.__init__(self, *args, **kwargs)

        LOG.error("ConfigFile: %s " % config['__file__'])

        conffile = config['__file__']

        if pylons.test.pylonsapp:
            wsgiapp = pylons.test.pylonsapp
        else:
            wsgiapp = loadapp('config: %s' % config['__file__'])

        self.app = TestApp(wsgiapp)

        conf = None
        if conffile.startswith('/'):
            conf = appconfig('config:%s' % config['__file__'], relative_to=None)
        else:
            raise Exception('dont know how to load the application relatively')
        #conf = appconfig('config: %s' % config['__file__'], relative_to=rel)

        load_environment(conf.global_conf, conf.local_conf)
        self.appconf = conf

        url._push_object(URLGenerator(config['routes.map'], environ))

        self.isSelfTest = False
        if env.has_key("privacyidea.selfTest"):
            self.isSelfTest = True

        self.license = 'CE'
        return
Esempio n. 11
0
 def __init__(self, *args, **kwargs):
     import sys
     self.wsgiapp = pylons.test.pylonsapp
     self.config = self.wsgiapp.config
     self.app = fixture.TestApp(self.wsgiapp)
     url._push_object(URLGenerator(self.config['routes.map'], environ))
     
     TestRollback.__init__(self, *args, **kwargs)
Esempio n. 12
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = webtest.TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     self.__setattrs__()
     self.__setcreateparams__()
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 13
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = OptionsTestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
     self.from_date = datetime(1990,1,1).isoformat() + "Z"
     self.controllerName = None
Esempio n. 14
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
     self.from_date = datetime(1990, 1, 1).isoformat() + "Z"
     self.until_date = datetime.utcnow().isoformat() + "Z"
Esempio n. 15
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = webtest.TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     self.__setattrs__()
     self.__setcreateparams__()
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 16
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        TestCase.__init__(self, *args, **kwargs)

        self.pkey, self.cert = _generate_mock_cert()
Esempio n. 17
0
    def __init__(self, *args, **kwargs):
        self.authz_file = os.path.dirname(__file__) + '/../../config/svn.access.test'

        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        TestCase.__init__(self, *args, **kwargs)
Esempio n. 18
0
    def __init__(self, *args, **kwargs):
        import sys
        self.wsgiapp = pylons.test.pylonsapp
        self.config = self.wsgiapp.config
        self.app = fixture.TestApp(self.wsgiapp)
        url._push_object(URLGenerator(self.config['routes.map'], environ))

        TestRollback.__init__(self, *args, **kwargs)
Esempio n. 19
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.application.config
     self.config = config
     self.app = TestApp(wsgiapp)
     self.g = self.config['pylons.app_globals']
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.application.config
     self.config = config
     self.app = TestApp(wsgiapp)
     self.g = self.config['pylons.app_globals']
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 21
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config

        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        self.Session = Session
        self.index_location = config['app_conf']['index_dir']
        TestCase.__init__(self, *args, **kwargs)
Esempio n. 22
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config

        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        self.Session = Session
        self.index_location = config['app_conf']['index_dir']
        TestCase.__init__(self, *args, **kwargs)
Esempio n. 23
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        # should perhaps be in setup
        pylons.app_globals._push_object(Globals(config))
        # pylons.app_globals._pop_object() # should perhaps be in teardown

        super(TestControllerBase, self).__init__(*args, **kwargs)
Esempio n. 24
0
def init_stack(config=None):
    if not config:
        config = pylons.test.pylonsapp.config
    url._push_object(URLGenerator(config['routes.map'], environ))
    pylons.app_globals._push_object(config['pylons.app_globals'])
    pylons.config._push_object(config)
    pylons.tmpl_context._push_object(ContextObj())
    # Initialize a translator for tests that utilize i18n
    translator = _get_translator(pylons.config.get('lang'))
    pylons.translator._push_object(translator)
Esempio n. 25
0
 def __init__(self, *args, **kwargs):
     #~ if pylons.test.pylonsapp:
         #~ wsgiapp = pylons.test.pylonsapp
     #~ else:
         #~ wsgiapp = loadapp('config:%s' % config['__file__'])
     wsgiapp = pylons.test.pylonsapp
     self.config = wsgiapp.config
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(self.config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 26
0
def init_stack(config=None):
    if not config:
        config = pylons.test.pylonsapp.config
    url._push_object(URLGenerator(config['routes.map'], environ))
    pylons.app_globals._push_object(config['pylons.app_globals'])
    pylons.config._push_object(config)
    pylons.tmpl_context._push_object(ContextObj())
    # Initialize a translator for tests that utilize i18n
    translator = _get_translator(pylons.config.get('lang'))
    pylons.translator._push_object(translator)
Esempio n. 27
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        # should perhaps be in setup
        pylons.app_globals._push_object(Globals(config))
        # pylons.app_globals._pop_object() # should perhaps be in teardown

        super(TestControllerBase, self).__init__(*args, **kwargs)
Esempio n. 28
0
    def __init__(self, *args, **kwargs):
        if pylons.test.pylonsapp:
            wsgiapp = pylons.test.pylonsapp
        else:
            wsgiapp = loadapp('config:%s' % config['__file__'])
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        # should perhaps be in setup
        pylons.app_globals._push_object(Globals())
        # pylons.app_globals._pop_object() # should perhaps be in teardown

        super(TestControllerBase, self).__init__(*args, **kwargs)
Esempio n. 29
0
    def __init__(self, *args, **kwargs):
        if pylons.test.pylonsapp:
            wsgiapp = pylons.test.pylonsapp
        else:
            wsgiapp = loadapp('config:%s' % config['__file__'])
        self.app = TestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        # should perhaps be in setup
        pylons.app_globals._push_object(Globals())
        # pylons.app_globals._pop_object() # should perhaps be in teardown

        super(TestControllerBase, self).__init__(*args, **kwargs)
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = OptionsTestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
     self.from_date = datetime(1990,1,1).isoformat() + "Z"
     self.controllerName = None
     def get_wsgiapp():
         return wsgiapp
     wsgi_intercept.add_wsgi_intercept('localhost', 80, get_wsgiapp)
     wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_wsgiapp)
Esempio n. 31
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''

        wsgiapp = pylons.test.pylonsapp
        self.app = webtest.TestApp(wsgiapp)

        self.session = 'justatest'
        self.resolvers = {}  # Set up of resolvers in create_common_resolvers

        # dict of all autheticated users cookies
        self.user_service = {}

        url._push_object(URLGenerator(config['routes.map'], environ))
        unittest2.TestCase.__init__(self, *args, **kwargs)

        self.appconf = config
        self.here = self.appconf.get('here')

        self.fixture_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), 'functional',
            'fixtures',
        )

        # ------------------------------------------------------------------ --

        current_webtest = LooseVersion(
            pkg_resources.get_distribution('webtest').version
        )
        if current_webtest <= LooseVersion('2.0.14'):
            # Fix application cookies for localhost for webtest versions
            # 2.0.0 to 2.0.14 (https://github.com/Pylons/webtest/issues/84)
            # The CookiePolicy code is taken from webtest

            class CookiePolicy(cookielib.DefaultCookiePolicy):
                """A subclass of DefaultCookiePolicy to allow cookie set for
                Domain=localhost."""

                def return_ok_domain(self, cookie, request):
                    if cookie.domain == '.localhost':
                        return True
                    return cookielib.DefaultCookiePolicy.return_ok_domain(
                        self, cookie, request)

                def set_ok_domain(self, cookie, request):
                    if cookie.domain == '.localhost':
                        return True
                    return cookielib.DefaultCookiePolicy.set_ok_domain(
                        self, cookie, request)

            self.app.cookiejar = cookielib.CookieJar(policy=CookiePolicy())
Esempio n. 32
0
    def __init__(self, *args, **kwargs):
        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
        config = wsgiapp.config
        pylons.app_globals._push_object(config['pylons.app_globals'])
        pylons.config._push_object(config)

        # Initialize a translator for tests that utilize i18n
        translator = _get_translator(pylons.config.get('lang'))
        pylons.translator._push_object(translator)

        url._push_object(URLGenerator(config['routes.map'], environ))
        self.app = TestApp(wsgiapp)
        TestCase.__init__(self, *args, **kwargs)
Esempio n. 33
0
 def __init__(self, *args, **kwargs):
     wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
     config = wsgiapp.config
     pylons.app_globals._push_object(config['pylons.app_globals'])
     pylons.config._push_object(config)
     
     # Initialize a translator for tests that utilize i18n
     translator = _get_translator(pylons.config.get('lang'))
     pylons.translator._push_object(translator)
     
     url._push_object(URLGenerator(config['routes.map'], environ))
     self.app = TestApp(wsgiapp)
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 34
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = OptionsTestApp(wsgiapp)
        url._push_object(URLGenerator(config['routes.map'], environ))
        TestCase.__init__(self, *args, **kwargs)
        self.from_date = datetime(1990, 1, 1).isoformat() + "Z"
        self.controllerName = None

        def get_wsgiapp():
            return wsgiapp

        wsgi_intercept.add_wsgi_intercept('localhost', 80, get_wsgiapp)
        wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_wsgiapp)
Esempio n. 35
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''

        wsgiapp = pylons.test.pylonsapp
        self.app = webtest.TestApp(wsgiapp)
        self.session = 'justatest'
        self.resolvers = {} # Set up in create_common_resolvers

        url._push_object(URLGenerator(config['routes.map'], environ))
        unittest2.TestCase.__init__(self, *args, **kwargs)

        self.appconf = config
Esempio n. 36
0
    def __init__(self, *args, **kwargs):
        '''
        initialize the test class
        '''

        wsgiapp = pylons.test.pylonsapp
        self.app = webtest.TestApp(wsgiapp)
        self.session = 'justatest'
        self.resolvers = {}  # Set up in create_common_resolvers

        url._push_object(URLGenerator(config['routes.map'], environ))
        unittest2.TestCase.__init__(self, *args, **kwargs)

        self.appconf = config
Esempio n. 37
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)

        url._push_object(URLGenerator(config['routes.map'], environ))        
        
        response = self.app.get(url(controller='users', action='login'))        
        form = response.form
        form['login'] = '******'
        form['password'] = '******'        
        response = form.submit()
        
        TestCase.__init__(self, *args, **kwargs)
Esempio n. 38
0
    def _push_custom_urls(self):
        """
        Push custom URL function to generate proper URLs for
        external pages (i.e. http://mif.vu.lt/ututi/teachers)
        as well as internal pages (i.e. http://ututi.com/about.

        We use absolute URLs, otherwise pylons redirect() makes
        up wrong URLs (it does not use url function).

        Example configuration for external server:

        RewriteRule ^/ututi(/(.*))?$ http://ututi.com/school/uni$2 [P,L]
        RequestHeader add X-Vhm-Root mif.vu.lt
        RequestHeader add X-Vhm-Root-Dir /ututi
        RequestHeader add X-Vhm-Host-Dir /school/uni
        """

        if hasattr(self, '_pushed_url_object'):
            return

        ututi_host = request.headers.get('Host')
        ututi_dir = request.headers.get('X-Vhm-Host-Dir')
        external_host = request.headers.get('X-Vhm-Root')
        external_dir = request.headers.get('X-Vhm-Root-Dir', '')

        if ututi_dir:
            orig_url = url._current_obj()

            def new_url(*args, **kwargs):
                urlstring = orig_url(*args, **kwargs)
                kwargs['qualified'] = True
                if urlstring.startswith(ututi_dir):
                    kwargs['host'] = external_host
                    return orig_url(*args, **kwargs)\
                            .replace(ututi_dir, external_dir, 1)
                else:
                    kwargs['host'] = ututi_host
                    return orig_url(*args, **kwargs)

            def current_url_proxy(*args, **kwargs):
                # TODO: reimplement the same logic as in new_url,
                # so we don't depend on internal _use_current parameter.
                kwargs['_use_current'] = True
                return new_url(*args, **kwargs)

            new_url.current = current_url_proxy
            url._push_object(new_url)
            self._pushed_url_object = new_url
Esempio n. 39
0
    def __init__(self, *args, **kwargs):
        wsgiapp = pylons.test.pylonsapp
        config = wsgiapp.config
        self.app = TestApp(wsgiapp)
        uri._push_object(URLGenerator(config['routes.map'], environ))

        self.driver_type = config.get('selenium.default_driver', 'Firefox')

        # TODO: use env to get SELENIUM_TARGET?
        self.server = config.get('selenium.default_server', 'http://127.0.0.1:5000')

        reldir = self.__reldir
        reltest_dirs = config.get('nose.selenium.test_paths', '').split(',')
        if reldir != '.' and reldir not in reltest_dirs:
            raise nose.exc.SkipTest('%s not in directory specified in nose.selenium.testdirs for given config' % self.__class__.__name__)
        super(SeleniumContextTest, self).__init__(*args, **kwargs)
Esempio n. 40
0
        def __init__(self, *args, **kwargs):
            super(TestController2, self).__init__(*args, **kwargs)

            # In case we detach controller from previous standard version,
            # we need to implement (at least for short amount of time)
            # support for Pylons and WebTest.
            import webtest
            import pylons.test
            from routes.util import URLGenerator

            environ = {}
            wsgiapp = pylons.test.pylonsapp
            config = pylons.test.pylonsapp.config

            self.app = webtest.TestApp(wsgiapp, environ)
            self.session = 'justatest'
            #self.appconf = config

            # Configure url ...
            url._push_object(URLGenerator(config['routes.map'], environ))

            # -------------------------------------------------------------- --

            current_webtest = LooseVersion(
                pkg_resources.get_distribution('webtest').version)
            if current_webtest <= LooseVersion('2.0.14'):
                # Fix application cookies for localhost for webtest versions
                # 2.0.0 to 2.0.14 (https://github.com/Pylons/webtest/issues/84)
                # The CookiePolicy code is taken from webtest

                class CookiePolicy(cookielib.DefaultCookiePolicy):
                    """A subclass of DefaultCookiePolicy to allow cookie set
                    for Domain=localhost."""
                    def return_ok_domain(self, cookie, request):
                        if cookie.domain == '.localhost':
                            return True
                        return cookielib.DefaultCookiePolicy.return_ok_domain(
                            self, cookie, request)

                    def set_ok_domain(self, cookie, request):
                        if cookie.domain == '.localhost':
                            return True
                        return cookielib.DefaultCookiePolicy.set_ok_domain(
                            self, cookie, request)

                self.app.cookiejar = cookielib.CookieJar(policy=CookiePolicy())
Esempio n. 41
0
        def __init__(self, *args, **kwargs):
            super(TestController2, self).__init__(*args, **kwargs)

            # In case we detach controller from previous standard version,
            # we need to implement (at least for short amount of time)
            # support for Pylons and WebTest.
            import webtest
            import pylons.test
            from routes.util import URLGenerator

            environ = {}
            wsgiapp = pylons.test.pylonsapp
            config = pylons.test.pylonsapp.config

            self.app = webtest.TestApp(wsgiapp, environ)
            self.session = 'justatest'
            #self.appconf = config

            # Configure url ...
            url._push_object(URLGenerator(config['routes.map'], environ))
Esempio n. 42
0
        def __init__(self, *args, **kwargs):
            super(TestController2, self).__init__(*args, **kwargs)

            # In case we detach controller from previous standard version,
            # we need to implement (at least for short amount of time)
            # support for Pylons and WebTest.
            import webtest
            import pylons.test
            from routes.util import URLGenerator

            environ = {}
            wsgiapp = pylons.test.pylonsapp
            config = pylons.test.pylonsapp.config

            self.app = webtest.TestApp(wsgiapp, environ)
            self.session = 'justatest'
            #self.appconf = config

            # Configure url ...
            url._push_object(URLGenerator(config['routes.map'], environ))
Esempio n. 43
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp, extra_environ={'REMOTE_ADDR': '0.0.0.0'})
     url._push_object(
         URLGenerator(
             config['routes.map'],
             {
                 # pretend we are in an HTTP request
                 'wsgi.url_scheme':
                 'https',
                 'HTTP_HOST':
                 'www.civicboom.com',
                 # pretend routes middleware has added stuff
                 'wsgiorg.routing_args': (None, {
                     'action': u'titlepage',
                     'controller': u'misc',
                     'sub_domain': 'www'
                 })
             }))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 44
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 45
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp, extra_environ=dict(REMOTE_USER='******'))
     url._push_object(URLGenerator(config['routes.map'], environ))
     TestCase.__init__(self, *args, **kwargs)
Esempio n. 46
0
from pylons import app_globals as g
from r2.config.middleware import RedditApp

# unfortunately, because of the deep intertwinded dependency we have in the
# orm with app_globals, we unfortunately have to do some pylons-setup
# at import time
baseplate.events.EventQueue = Queue.Queue
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
pylons.app_globals._push_object(wsgiapp.config['pylons.app_globals'])
pylons.config._push_object(wsgiapp.config)

# Initialize a translator for tests that utilize i18n
translator = _get_translator(pylons.config.get('lang'))
pylons.translator._push_object(translator)

url._push_object(URLGenerator(pylons.config['routes.map'], {}))


def diff_dicts(d, expected, prefix=None):
    """Given 2 dicts, return a summary of their differences

    :param dict d: dict to match from ("got")
    :param dict expected: dict to match against ("want")
    :param prefix: key prefix (used for recursion)
    :type prefix: list or None
    :rtype: dict
    :returns: mapping of flattened keys to 2-ples of (got, want)
    """
    prefix = prefix or []
    diffs = {}
    for k in set(d.keys() + expected.keys()):
Esempio n. 47
0
 def __init__(self, *args, **kwargs):
     self.app = TestApp(pylonsapp)
     url._push_object(URLGenerator(config['routes.map'], {}))
     super(DatabaseTestCase, self).__init__(*args, **kwargs)
Esempio n. 48
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     super(DatabaseTestCase, self).__init__(*args, **kwargs)
Esempio n. 49
0
 def __init__(self):
     wsgiapp = pylons.test.pylonsapp
     config = wsgiapp.config
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
Esempio n. 50
0
from pylons import app_globals as g
from r2.config.middleware import RedditApp

# unfortunately, because of the deep intertwinded dependency we have in the
# orm with app_globals, we unfortunately have to do some pylons-setup
# at import time
baseplate.events.EventQueue = Queue.Queue
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
pylons.app_globals._push_object(wsgiapp.config['pylons.app_globals'])
pylons.config._push_object(wsgiapp.config)

# Initialize a translator for tests that utilize i18n
translator = _get_translator(pylons.config.get('lang'))
pylons.translator._push_object(translator)

url._push_object(URLGenerator(pylons.config['routes.map'], {}))


def diff_dicts(d, expected, prefix=None):
    """Given 2 dicts, return a summary of their differences

    :param dict d: dict to match from ("got")
    :param dict expected: dict to match against ("want")
    :param prefix: key prefix (used for recursion)
    :type prefix: list or None
    :rtype: dict
    :returns: mapping of flattened keys to 2-ples of (got, want)
    """
    prefix = prefix or []
    diffs = {}
    for k in set(d.keys() + expected.keys()):
 def testSetUp(self):
     config = pylons.test.pylonsapp.config
     translator = _get_translator(config.get('lang'), pylons_config=config)
     pylons.translator._push_object(translator)
     url._push_object(URLGenerator(pylons.test.pylonsapp.config['routes.map'], environ))
Esempio n. 52
0
 def __init__(self, *args, **kwargs):
     wsgiapp = pylons.test.pylonsapp
     self.app = TestApp(wsgiapp)
     url._push_object(URLGenerator(config['routes.map'], environ))
     super(DatabaseTestCase, self).__init__(*args, **kwargs)