当前位置: 首页>>代码示例>>Python>>正文


Python fanstatic.NeededResources类代码示例

本文整理汇总了Python中fanstatic.NeededResources的典型用法代码示例。如果您正苦于以下问题:Python NeededResources类的具体用法?Python NeededResources怎么用?Python NeededResources使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NeededResources类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_library_url_base_url

def test_library_url_base_url():
    foo = Library('foo', '')

    needed = NeededResources(base_url="http://example.com/something")

    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: test_rendering_base_url

def test_rendering_base_url():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources(resources=[y1])
    incl = Inclusion(needed)
    assert incl.render() == '''\
<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>'''

    needed = NeededResources(
        base_url='http://localhost/static', resources=[y1])
    incl = Inclusion(needed)
    assert incl.render() == '''\
<link rel="stylesheet" type="text/css" href="http://localhost/static/fanstatic/foo/b.css" />
<script type="text/javascript" src="http://localhost/static/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="http://localhost/static/fanstatic/foo/c.js"></script>'''
    # The base_url has been set.
    assert needed.has_base_url()

    needed.set_base_url('foo')
    # The base_url can only be set once.
    assert needed._base_url == 'http://localhost/static'
开发者ID:fsys,项目名称:fanstatic,代码行数:26,代码来源:test_core.py

示例3: test_library_ordering_bug

def test_library_ordering_bug():
    jquery_lib = Library('jquery', '')
    jqueryui_lib = Library('jqueryui', '')
    obviel_lib = Library('obviel', '')
    bread_lib = Library('bread', '')
    app_lib = Library('app', '')

    jquery = Resource(jquery_lib, 'jquery.js')
    jqueryui = Resource(jqueryui_lib, 'jqueryui.js', depends=[jquery])

    obviel = Resource(obviel_lib, 'obviel.js', depends=[jquery])
    obviel_forms = Resource(obviel_lib, 'obviel_forms.js',
                            depends=[obviel])
    obviel_datepicker = Resource(obviel_lib, 'obviel_datepicker.js',
                                 depends=[obviel_forms, jqueryui])

    vtab = Resource(bread_lib, 'vtab.js', depends=[jqueryui])

    tabview = Resource(bread_lib, 'tabview.js', depends=[obviel, vtab])

    bread = Resource(bread_lib, 'bread.js', depends=[tabview, obviel_forms])

    app = Resource(app_lib, 'app.js', depends=[bread, obviel_datepicker])

    needed = NeededResources()

    needed.need(app)
    resources = needed.resources()
    for resource in resources:
        print resource, resource.library.library_nr
    assert resources == [jquery, jqueryui, obviel, obviel_forms,
                         obviel_datepicker, vtab, tabview, bread, app]
开发者ID:MiCHiLU,项目名称:fanstatic-gae,代码行数:32,代码来源:test_core.py

示例4: test_slot_with_default_uses_default_if_nothing_given_in_need

def test_slot_with_default_uses_default_if_nothing_given_in_need():
    lib = Library("lib", "")
    default_resource_for_slot = Resource(lib, "b.js")
    slot = Slot(lib, ".js", default=default_resource_for_slot)
    a = Resource(lib, "a.js", depends=[slot])
    needed = NeededResources(resources=[a])
    relpaths = [r.relpath for r in sort_resources(needed.resources())]
    assert relpaths == ["b.js", "a.js"]
开发者ID:,项目名称:,代码行数:8,代码来源:

示例5: test_no_need_to_fill_in_not_required

def test_no_need_to_fill_in_not_required():
    lib = Library("lib", "")
    slot = Slot(lib, ".js", required=False)
    a = Resource(lib, "a.js", depends=[slot])

    needed = NeededResources(resources=[a])
    # slot wasn't required and not filled in, so filled slot doesn't show up
    assert needed.resources() == set([a])
开发者ID:,项目名称:,代码行数:8,代码来源:

示例6: test_html_insert_head_with_attributes

def test_html_insert_head_with_attributes():
    # ticket 72: .need() broken when <head> tag has attributes
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    needed = NeededResources(resources=[x1])

    html = '<html><head profile="http://example.org">something</head></html>'
    assert needed.render_into_html(html) == '''\
开发者ID:MiCHiLU,项目名称:fanstatic-gae,代码行数:8,代码来源:test_core.py

示例7: test_library_url_script_name_base_url

def test_library_url_script_name_base_url():
    foo = Library('foo', '')
    needed = NeededResources(
        script_name='/root', base_url="http://example.com/something")

    # base_url is set so script_name should be ignored
    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
开发者ID:MiCHiLU,项目名称:fanstatic-gae,代码行数:8,代码来源:test_core.py

示例8: test_empty_base_url_and_publisher_signature

def test_empty_base_url_and_publisher_signature():
    ''' When the base_url is not set and the publisher_signature is an empty string,
    render a URL without them. '''
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    needed = NeededResources(publisher_signature='')
    needed.need(x1)

    assert needed.render() == '''\
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: test_bundle_single_dont_bundle_entry

def test_bundle_single_dont_bundle_entry():
    foo = Library('foo', '')
    a = Resource(foo, 'a.js', dont_bundle=True)

    needed = NeededResources(bundle=True)
    needed.need(a)
    resources = needed.resources()

    assert resources == [a]
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: test_rollup_without_mode

def test_rollup_without_mode():
    foo = Library('foo', '')
    h1 = Resource(foo, 'h1.js', debug='h1-debug.js')
    h2 = Resource(foo, 'h2.js', debug='h2-debug.js')
    gianth = Resource(foo, 'gianth.js', supersedes=[h1, h2])

    needed = NeededResources(resources=[h1, h2], rollup=True, debug=True)
    # no mode available for rollup, use the rollup.
    assert needed.resources() == [gianth]
开发者ID:,项目名称:,代码行数:9,代码来源:

示例11: test_rendering

def test_rendering():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources()
    needed.need(y1)

    assert needed.render() == '''\
开发者ID:,项目名称:,代码行数:10,代码来源:

示例12: test_resource

def test_resource():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources()
    needed.need(y1)

    assert needed.resources() == set([x2, x1, y1])
开发者ID:fsys,项目名称:fanstatic,代码行数:10,代码来源:test_core.py

示例13: test_bundle_single_entry

def test_bundle_single_entry():
    # we can successfully bundle a single resource (it's not bundled though)
    foo = Library('foo', '')
    a = Resource(foo, 'a.js')

    needed = NeededResources(bundle=True)
    needed.need(a)
    resources = needed.resources()

    assert resources == [a]
开发者ID:,项目名称:,代码行数:10,代码来源:

示例14: test_rendering_base_url_assign

def test_rendering_base_url_assign():
    foo = Library('foo', '')
    x1 = Resource(foo, 'a.js')
    x2 = Resource(foo, 'b.css')
    y1 = Resource(foo, 'c.js', depends=[x1, x2])

    needed = NeededResources(resources=[y1])
    needed.set_base_url('http://localhost/static')
    incl = Inclusion(needed)
    assert incl.render() == '''\
开发者ID:fsys,项目名称:fanstatic,代码行数:10,代码来源:test_core.py

示例15: test_normalize_string

def test_normalize_string():
    foo = Library('foo', '')
    assert isinstance(normalize_string(foo, 'f.css'), Resource)
    r1 = Resource(foo, 'f.js')
    assert normalize_string(foo, r1) == r1

    r2 = Resource(foo, 'r2.css')
    r3 = Resource(foo, 'r3.css', depends=[r2], minified='r3.min.css')
    needed = NeededResources(minified=True, resources=[r3])
    assert needed.resources() == [r2, r3.modes['minified']]
开发者ID:,项目名称:,代码行数:10,代码来源:


注:本文中的fanstatic.NeededResources类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。