示例#1
0
 def test_load_related_none_found(self):
     with pytest.raises(AssetException) as e:
         am = AssetManager(keg.current_app)
         am.load_related('_not_there.html')
         assert six.text_type(
             e
         ) == 'Could not find related assets for template: _not_there.html'
示例#2
0
    def test_load_related(self):
        am = AssetManager(keg.current_app)
        am.load_related('assets_in_template.html')

        assert len(am.content['js']) == 1
        asset_name, filepath, content = am.content['js'].pop()
        assert asset_name == 'assets_in_template.js'
        assert filepath.endswith('keg_apps/templating/templates/assets_in_template.js')
        assert content.strip() == '//assets_in_template js file'

        assert len(am.content['css']) == 1
        asset_name, filepath, content = am.content['css'].pop()
        assert asset_name == 'assets_in_template.css'
        assert filepath.endswith('keg_apps/templating/templates/assets_in_template.css')
        assert content.strip() == '/* assets_in_template css file */'
示例#3
0
    def test_load_related(self):
        am = AssetManager(keg.current_app)
        am.load_related('assets_in_template.html')

        assert len(am.content['js']) == 1
        asset_name, filepath, content = am.content['js'].pop()
        assert asset_name == 'assets_in_template.js'
        assert filepath.endswith(
            os.path.join('keg_apps', 'templating', 'templates',
                         'assets_in_template.js'))
        assert content.strip() == '//assets_in_template js file'

        assert len(am.content['css']) == 1
        asset_name, filepath, content = am.content['css'].pop()
        assert asset_name == 'assets_in_template.css'
        assert filepath.endswith(
            os.path.join('keg_apps', 'templating', 'templates',
                         'assets_in_template.css'))
        assert content.strip() == '/* assets_in_template css file */'
示例#4
0
    def test_load_single_asset(self):
        am = AssetManager(keg.current_app)
        am.load_related('assets_include_single.html')

        assert len(am.content['js']) == 1
        assert len(am.content['css']) == 0
示例#5
0
 def __init__(self, app, environ, request=None):
     super(KegRequestContext, self).__init__(app, environ, request)
     self.assets = AssetManager(app)
示例#6
0
    def test_load_single_asset(self):
        am = AssetManager(keg.current_app)
        am.load_related('assets_include_single.html')

        assert len(am.content['js']) == 1
        assert len(am.content['css']) == 0
示例#7
0
 def test_load_related_none_found(self):
     with pytest.raises(AssetException) as e:
         am = AssetManager(keg.current_app)
         am.load_related('_not_there.html')
         assert six.text_type(e) == 'Could not find related assets for template: _not_there.html'