Exemplo n.º 1
0
def test_bundle_resources_bottomsafe():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css', bottom=True)

    needed = NeededResources(resources=[a,b], bundle=True)
    assert needed.render_topbottom() == ('''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/:bundle:a.css;b.css" />''', '')

    needed = NeededResources(resources=[a,b], bundle=True, bottom=True)
    assert needed.render_topbottom() == ('''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/a.css" />''', '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />''')
Exemplo n.º 2
0
def test_bundle_resources_bottomsafe():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css', bottom=True)

    needed = NeededResources(resources=[a, b], bundle=True)
    assert needed.render_topbottom() == ('''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/:bundle:a.css;b.css" />''',
                                         '')

    needed = NeededResources(resources=[a, b], bundle=True, bottom=True)
    assert needed.render_topbottom() == ('''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/a.css" />''', '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />''')
Exemplo n.º 3
0
def test_html_bottom_safe_used_with_minified():
    foo = Library('foo', '')
    a = Resource(foo, 'a.js', minified='a-minified.js', bottom=True)

    needed = NeededResources(minified=True, bottom=True)
    needed.need(a)

    top, bottom = needed.render_topbottom()
    assert top == ''
    assert bottom == ('<script type="text/javascript" '
                      'src="/fanstatic/foo/a-minified.js"></script>')
Exemplo n.º 4
0
def test_html_bottom_safe_used_with_minified():
    foo = Library('foo', '')
    a = Resource(foo, 'a.js', minified='a-minified.js', bottom=True)

    needed = NeededResources(minified=True, bottom=True)
    needed.need(a)

    top, bottom = needed.render_topbottom()
    assert top == ''
    assert bottom == ('<script type="text/javascript" '
                      'src="/fanstatic/foo/a-minified.js"></script>')
Exemplo n.º 5
0
def test_html_top_bottom_force_bottom():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources(bottom=True, force_bottom=True)
    needed.need(y1)

    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />'''
    assert bottom == '''\
Exemplo n.º 6
0
def test_html_top_bottom_force_bottom():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources(bottom=True, force_bottom=True)
    needed.need(y1)

    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />'''
    assert bottom == '''\
Exemplo n.º 7
0
def test_html_bottom_safe():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])
    y2 = Resource(foo, 'y2.js', bottom=True)

    needed = NeededResources()
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />
<script type="text/javascript" src="/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="/fanstatic/foo/y2.js"></script>
<script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
    assert bottom == ''

    needed = NeededResources(bottom=True)
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />
<script type="text/javascript" src="/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
    assert bottom == '''\
<script type="text/javascript" src="/fanstatic/foo/y2.js"></script>'''

    needed = NeededResources(bottom=True, force_bottom=True)
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />'''
    assert bottom == '''\
Exemplo n.º 8
0
def test_html_bottom_safe():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])
    y2 = Resource(foo, 'y2.js', bottom=True)

    needed = NeededResources()
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />
<script type="text/javascript" src="/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="/fanstatic/foo/y2.js"></script>
<script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
    assert bottom == ''

    needed = NeededResources(bottom=True)
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />
<script type="text/javascript" src="/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
    assert bottom == '''\
<script type="text/javascript" src="/fanstatic/foo/y2.js"></script>'''

    needed = NeededResources(bottom=True, force_bottom=True)
    needed.need(y1)
    needed.need(y2)
    top, bottom = needed.render_topbottom()
    assert top == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />'''
    assert bottom == '''\