Exemplo n.º 1
0
    def test_includeme(self):
        from pyramid_webassets import includeme
        from pyramid_webassets import add_webasset
        from pyramid_webassets import get_webassets_env
        from pyramid_webassets import get_webassets_env_from_request

        config = Mock()
        add_directive = Mock()
        registerUtility = Mock()
        set_request_property = Mock()

        config.registry = Mock()
        config.registry.registerUtility = registerUtility
        config.add_directive = add_directive
        config.set_request_property = set_request_property

        settings = {
            'webassets.base_url': '/static',
            'webassets.base_dir': '/home/sontek',
        }

        config.registry.settings = settings

        includeme(config)

        expected1 = ('add_webasset', add_webasset)
        expected2 = ('get_webassets_env', get_webassets_env)
        assert add_directive.call_args_list[0][0] == expected1
        assert add_directive.call_args_list[1][0] == expected2

        assert set_request_property.call_args_list[0][0] == \
            (get_webassets_env_from_request, 'webassets_env')
Exemplo n.º 2
0
    def test_includeme(self):
        from pyramid_webassets import includeme
        from pyramid_webassets import add_webasset
        from pyramid_webassets import get_webassets_env

        config = Mock()
        add_directive = Mock()
        registerUtility = Mock()

        config.registry = Mock()
        config.registry.registerUtility = registerUtility
        config.add_directive = add_directive

        settings = {
            'webassets.base_url': '/static',
            'webassets.base_dir': '/home/sontek',
        }

        config.registry.settings = settings

        includeme(config)

        expected1 = ('add_webasset', add_webasset)
        expected2 = ('get_webassets_env', get_webassets_env)
        assert add_directive.call_args_list[0][0] == expected1
        assert add_directive.call_args_list[1][0] == expected2
Exemplo n.º 3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(root_factory=root_factory, settings=settings)

    includeme(config)
    jsengine = Bundle('app/vendor/jquery-1.8.2.js',
            'app/vendor/bootstrap-2.3.0/js/bootstrap.js',
            'app/vendor/handlebars-1.0.0-rc.3.js',
            'app/vendor/ember-1.0.0-rc.1.js',
            'app/vendor/ember-data.js',
            filters='rjsmin',
            output='js/main.js', debug=False)
    templates = Bundle('app/templates/*.handlebars',
            'app/templates/*/*.handlebars',
            filters='jst',
            output='js/templates.js', debug=False)
    jsapp = Bundle('app/app.js',
            filters='rjsmin',
            output='js/app.js', debug=True)
    css = Bundle('app/vendor/bootstrap-2.3.0/css/bootstrap.css',
            'app/vendor/bootstrap-2.3.0/css/bootstrap-responsive.css',
            'app/css/app.css',
            filters='cssmin',
            output='css/main.css', debug=True)
    config.add_webasset('jsengine', jsengine)
    config.add_webasset('templates', templates)
    config.add_webasset('jsapp', jsapp)
    config.add_webasset('css', css)

    config.add_renderer('json', json_renderer)

    resolver = AssetResolver()
    static_path = resolver.resolve('pyred:static').abspath()
    config.add_static_view(name='static', path=static_path, cache_max_age=3600)

    config.scan()
    return config.make_wsgi_app()
Exemplo n.º 4
0
    def test_includeme(self):
        from pyramid_webassets import includeme
        from pyramid_webassets import add_webasset
        from pyramid_webassets import get_webassets_env
        from pyramid_webassets import add_setting
        from pyramid_webassets import get_webassets_env_from_request

        config = Mock()
        add_directive = Mock()
        registerUtility = Mock()
        set_request_property = Mock()

        config.registry = Mock()
        config.registry.registerUtility = registerUtility
        config.add_directive = add_directive
        config.set_request_property = set_request_property

        settings = {
            'webassets.base_url': 'static',
            'webassets.base_dir': os.getcwd(),
        }

        config.registry.settings = settings

        includeme(config)

        expected1 = ('add_webasset', add_webasset)
        expected2 = ('get_webassets_env', get_webassets_env)
        expected3 = ('add_webassets_setting', add_setting)

        assert add_directive.call_args_list[0][0] == expected1
        assert add_directive.call_args_list[1][0] == expected2
        assert add_directive.call_args_list[2][0] == expected3

        assert set_request_property.call_args_list[0][0] == \
            (get_webassets_env_from_request, 'webassets_env')
    def test_includeme(self):
        from pyramid_webassets import includeme
        from pyramid_webassets import add_webasset
        from pyramid_webassets import get_webassets_env
        from pyramid_webassets import add_setting
        from pyramid_webassets import get_webassets_env_from_request

        config = Mock()
        add_directive = Mock()
        registerUtility = Mock()
        add_request_method = Mock()

        config.registry = Mock()
        config.registry.registerUtility = registerUtility
        config.add_directive = add_directive
        config.add_request_method = add_request_method

        settings = {
            'webassets.base_url': 'static',
            'webassets.base_dir': os.getcwd(),
        }

        config.registry.settings = settings

        includeme(config)

        expected1 = ('add_webasset', add_webasset)
        expected2 = ('get_webassets_env', get_webassets_env)
        expected3 = ('add_webassets_setting', add_setting)

        assert add_directive.call_args_list[0][0] == expected1
        assert add_directive.call_args_list[1][0] == expected2
        assert add_directive.call_args_list[2][0] == expected3

        assert add_request_method.call_args_list[0][0] == \
            (get_webassets_env_from_request, 'webassets_env')