Source

WebHelpers / tests / util.py

from unittest import TestCase

import routes

class WebHelpersTestCase(TestCase):
    """Establishes a faux-environment for tests"""
    def test_environ(self):
        return {
            'HTTP_HOST': 'bob.local:5000',
            'PATH_INFO': '/test',
            'QUERY_STRING': 'test=webhelpers&framework=pylons',
            'REQUEST_METHOD': 'GET',
            'SERVER_NAME': '0.0.0.0',
            'SCRIPT_NAME': '',
            'pylons.environ_config': dict(session='test.session'),
            'test.session': {},
            'wsgi.multiprocess': False,
            'wsgi.multithread': True,
            'wsgi.run_once': False,
            'wsgi.url_scheme': 'http'
            }

    def setUp(self):
        map = routes.Mapper()
        map.connect('test')
        map.connect(':controller/:action/:id')

        self.routes_config = routes.request_config()
        self.routes_config.mapper = map
        self.routes_config.environ = self.test_environ()
        assert self.routes_config.mapper_dict
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.