Exemplo n.º 1
0
def test_will_rollup_with_lessc():
    settings.SKYLARK_PLANS = "mediadeploy_reusable"

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/lessc.yaml", c)

    content = pa.dumps()

    assert "cfcache/out/planapp/page/media/css/lessjs.css" in content
    assert '<link rel="stylesheet"' in content

    settings.SKYLARK_PLANS = "mediadeploy_fewest"

    hash_css = "8015602c1f5583386d62d1478e2a8442"
    filename = os.path.join(cachedir, "out", "%s.css" % hash_css)

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/lessc.yaml", c)

    content = pa.dumps()

    assert (
        '<link rel="stylesheet" type="text/css" '
        'href="http://*****:*****@less" not in css_file
    assert "cfcache/out/planapp/page/media/img/header.png" in css_file
Exemplo n.º 2
0
def test_will_not_needlessly_rollup():
    settings.SKYLARK_PLANS = "mediadeploy_reusable"

    hash_js1 = "d921f357906a0e5e06da6a704376247b"
    filename = os.path.join(cachedir, "out", "%s.js" % hash_js1)

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    first_time = os.stat(filename).st_mtime
    first_listing = os.listdir(os.path.join(cachedir, "out"))

    sleep(1.0)

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    assert first_time == os.stat(filename).st_mtime
    assert first_listing == os.listdir(os.path.join(cachedir, "out"))
Exemplo n.º 3
0
def test_will_use_correct_doctype():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/sample.yaml", c)

    content = pa.dumps()

    assert "<!DOCTYPE html>" in content

    pa = PageAssembly("dummyapp/page/xhtmlstrict.yaml", c)

    content = pa.dumps()

    assert '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' in content
    assert "xhtml1-strict.dtd" in content

    exist(
        "out/dummyapp/page/media/css/sample.css",
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/notreferenced.js",
        "out/dummyapp/page/media/js/sample.js",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )
Exemplo n.º 4
0
def test_chirp_renders_in_page():
    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)

    content = pa.dumps()

    exist(
        'addon/dojo/dojo.js',
        'addon/dojox/timing/_base.js',
        'out/dummyapp/page/media/img/notreferenced.png',
        'out/dummyapp/page/media/img/test.png',
        'out/dummyapp/page/media/js/sample.js',
        'out/dummyapp/page/media/js/templates/notreferenced.html',
        'out/dummyapp/page/media/js/templates/sample.js',
        'out/dummyapp/tag/media/css/screen.css',
        'out/dummyapp/tag/media/img/testimage.png',
        'out/dummyapp/tag/media/js/templates/test.html',
        'out/dynamicapp/media/js/chirploaded.js',
        'out/dynamicapp/media/js/templates/chirploaded.html',
    )

    assert "dojo.registerModulePath('DynamicApp.Page'" in content
    assert "dojo.require('DynamicApp.Page.Controller');" in content
    assert "dojo.require('DynamicApp.Page.View');" in content
    assert 'dummyapp/tag/media/css/screen.css' in content
    assert 'dummyapp/page/media/js/sample.js' in content
    assert 'media/cfcache/out/dynamicapp' in content
    assert 'addon/dojo/dojo.js' in content
Exemplo n.º 5
0
def test_bb_issue_23():
    """
    Issue #23

    If you are rendering a page with a PageAssembly and that page contains a
    template tag that renders using SnippetAssembly, the underlying
    context['page_instructions'] object will be changed causing dependencies to
    be missed
    """
    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/issue_bb_23/issue_bb_23.yaml', c)

    content = pa.dumps()
    stuff = (
        'dummyapp/issue_bb_23/media/js/tt_after_sa.js',
        "dojo.registerModulePath('DummyApp.BB.Issue23.TTSa'",
        "dojo.require('DummyApp.BB.Issue23.TTSa.Controller');",
        "dojo.require('DummyApp.BB.Issue23.TTSa.View');",
        "dojo.registerModulePath('DummyApp.BB.Issue23.TTAfterSa'",
        "dojo.require('DummyApp.BB.Issue23.TTAfterSa.Controller');",
        "dojo.require('DummyApp.BB.Issue23.TTAfterSa.View');",
    )
    for item in stuff:
        assert item in stuff
        assert content.find(item) < content.find("<body>")
        assert content.count(item) == 1
Exemplo n.º 6
0
def test_will_tidy_output():
    assert settings.DEBUG
    settings.SKYLARK_ENABLE_TIDY = True
    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("dummyapp/page/sample.yaml", c)
    assert len(pa.dumps().split("\n")) == 42  # The answer to everything
Exemplo n.º 7
0
def test_bb_issue_19():
    """
    Issue #19

    If DEBUG=False, a cached directory may not contain all needed files

    With DEBUG=False, an existing directory will be ignored when creating the
    files within the cfcache.  The reason that this creates a problem, is that
    the directory may be created by another directive like js: -file:
    app/page/media/js/file.js and then another directive may add content to
    that same directory chirp: -location: app/page/media/js. The first js
    will create the directory and the chirp section will then be skipped.
    """
    settings.DEBUG = False
    settings.SKYLARK_PLANS = 'mediadeploy'
    settings.SKYLARK_PLANS_DEFAULT = 'rf'

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/issue_bb_19/issue_bb_19.yaml', c)

    content = pa.dumps()

    exist(
        'out/dummyapp/issue_bb_19/media/js/static.js',
        'out/dummyapp/issue_bb_19/media/js/Class.js',
        'out/dummyapp/issue_bb_19/media/js/templates/file.html',
    )
Exemplo n.º 8
0
def test_can_register_handlers():
    def handler(page_instructions, renderer, assembly):
        global handler_called
        assembly.add_page_instructions(page_instructions, "dummyapp/page/uses.yaml")
        handler_called = True
        assert page_instructions.other_yaml == ["dummyapp/page/uses.yaml"]
        assert page_instructions.uses_yaml == []
        assert page_instructions.root_yaml == "dummyapp/page/sample.yaml"

    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/sample.yaml", c)

    pa.register_handler(handler)
    # Make sure we can't get a dupe
    pa.register_handler(handler)

    assert len(BaseAssembly._page_assembly_handlers) == 1

    content = pa.dumps()

    assert handler_called

    pa.unregister_all()

    assert len(BaseAssembly._page_assembly_handlers) == 0
Exemplo n.º 9
0
def test_deploy_reusable():
    hash_js1 = '96936cfbde05fe1cce209c7f344dbd08'
    hash_js2 = 'd921f357906a0e5e06da6a704376247b'
    hash_css = 'f27f963509901f608889f688b1e39f72'

    settings.DEBUG = False
    settings.SKYLARK_PLANS = 'mediadeploy_reusable'

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly('planapp/page/full.yaml', c)

    content = pa.dumps()

    jsfile = get_contents(
        os.path.join(cachedir, 'out', '%s.js' % hash_js1)
    )
    assert 'var static_uses2=null;var static_uses1=null;' in jsfile

    jsfile = get_contents(
        os.path.join(cachedir, 'out', '%s.js' % hash_js2)
    )
    assert jsfile.find('dojo.provide("dojox.timing._base")') < \
        jsfile.find('dojo.provide("dojox.timing")')
    assert jsfile.find("dojo.provide('PlanApp.Page.View')") < \
        jsfile.find("dojo.provide('PlanApp.Page.Controller')")
    assert jsfile.find("dojo.registerModulePath('ChirpTools'") < \
        jsfile.find("dojo.provide('ChirpTools.Error')")
    assert "dojo.registerModulePath('ChirpTools" not in content

    cssfile = get_contents(
        os.path.join(cachedir, 'out', '%s.css' % hash_css)
    )
    assert '.static_uses2' in cssfile
    assert '.static_uses1' in cssfile
    assert 'url(http://localhost:8000/media/' in cssfile
    assert 'out/planapp/page/media/img/uses1.gif' in cssfile
    
    assert '%s.js' % hash_js1 in content
    assert '%s.js' % hash_js2 in content
    assert 'planapp/page/media/js/static_uses1.js' not in content
    assert 'planapp/page/media/js/static_uses2.js' not in content

    assert '%s.css' % hash_css in content
    assert 'planapp/page/media/css/static_uses1.css' not in content
    assert 'planapp/page/media/css/static_uses2.css' not in content

    assert content.find('addon/dojo.js') < \
        content.find('%s.js' % hash_js1)
    assert content.find('%s.js' % hash_js1) < \
        content.find('media/uses1.js')

    assert content.find('media/uses1.css') < \
        content.find('%s.css' % hash_css)
    assert content.find('%s.css' % hash_css) < \
        content.find('site.com/handheld.css')

    assert content.find('js/ie7only.css') < \
        content.find('%s.js' % hash_js2)
Exemplo n.º 10
0
def test_can_render_clevercss():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/clevercss.yaml", c)

    pa.dumps()

    media = (cachedir, "out", "dummyapp", "page", "media")
    css = get_contents(join(*media + ("css", "clevercss.css")))
    assert css == "body {\n  background-color: gray;\n}"

    exist(
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )
Exemplo n.º 11
0
def test_title_tag_is_escaped():
    request = get_request_fixture()
    c = RequestContext(request, {"title": unicode("Title < > ' \"")})
    pa = PageAssembly("dummyapp/page/escapetitle.yaml", c)

    content = pa.dumps()

    assert content.index("Title &lt; &gt; &#39; &quot;")
Exemplo n.º 12
0
def test_gh_issue_01():
    settings.SKYLARK_PLANS = 'mediadeploy_reusable'

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/issue_gh_01/issue_gh_01.yaml', c)

    content = pa.dumps()
    assert content
Exemplo n.º 13
0
def test_chirp_includes_tests():
    assert not chirp.is_instrumented()
    chirp.instrument_site(True)

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)
    content = pa.dumps()

    assert "dojo.require('DynamicApp.Page.Test')" in content

    chirp.instrument_site(False)

    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)
    content = pa.dumps()

    assert "dojo.require('DynamicApp.Page.Test')" not in content
Exemplo n.º 14
0
def test_handles_snippets_inside_page_assemblies():
    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("dummyapp/page/snippetinside.yaml", c)

    content = pa.dumps()

    assert content.count("DynamicApp.Snippet.Controller") == 1
    assert content.count("dummyapp/snippet/media/js/base.js") == 1
    assert content.count("dummyapp/page/media/js/sample.js") == 1
Exemplo n.º 15
0
def test_chirp_dojo_settings():
    settings.SKYLARK_DOJO_VIA_CDN_AOL = True

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)
    content = pa.dumps()
    assert 'http://o.aolcdn.com/dojo/1.4/dojo/dojo.xd.js' in content

    settings.SKYLARK_DOJO_VIA_CDN_AOL = None

    settings.SKYLARK_DOJO_VIA_URL = 'http://testdojo.com/dojo.js'

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)
    content = pa.dumps()
    assert 'http://testdojo.com/dojo.js' in content

    settings.SKYLARK_DOJO_VIA_URL = None
Exemplo n.º 16
0
def test_will_do_conditional_comments():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/ieversion.yaml", c)

    content = pa.dumps()

    # For the CSS
    assert "<!--[if gte IE 6]>" in content
    # This is for the JS, which we also support
    assert "<!--[if gte IE 7]>" in content
Exemplo n.º 17
0
def test_deploy_fewest():
    hash_css = "a30e20a6a1d62976266b612a7e5d634a"
    hash_js = "99cd70ab43d662a64aa33c794433295a"

    settings.SKYLARK_PLANS = "mediadeploy_fewest"

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    exist(
        "out/%s.css" % hash_css,
        "out/%s.js" % hash_js,
        "out/planapp/page/media/css/gte_ie6only.css",
        "out/planapp/page/media/img/uses1.gif",
        "out/planapp/page/media/img/uses2.gif",
        "out/planapp/page/media/js/Controller.js",
        "out/planapp/page/media/js/duplicated.js",
        "out/planapp/page/media/js/ie7only.js",
        "out/planapp/page/media/js/inline.js",
        "out/planapp/page/media/js/notreferenced.js",
        "out/planapp/page/media/js/static.js",
        "out/planapp/page/media/js/static_uses1.js",
        "out/planapp/page/media/js/static_uses2.js",
        "out/planapp/page/media/js/View.js",
    )

    jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js))
    assert "static_uses2" in jsfile
    assert "static_uses1" in jsfile
    assert "static=" in jsfile
    assert "duplicated" in jsfile
    assert jsfile.find("duplicated=null") < jsfile.find('dojo.provide("dojox.timing._base")')

    cssfile = get_contents(os.path.join(cachedir, "out", "%s.css" % hash_css))

    assert ".static_uses2" in cssfile
    assert ".static_uses1" in cssfile
    assert ".static {" in cssfile

    assert "%s.js" % hash_js in content
    assert "planapp/page/media/js/static" not in content
    assert "planapp/page/media/js/duplicated" not in content

    assert "%s.css" % hash_css in content

    assert content.find("addon/dojo") < content.find("%s.js" % hash_js)
    assert content.find("%s.js" % hash_js) < content.find("media/uses1.js")

    assert content.find("media/uses1.css") < content.find("%s.css" % hash_css)
    assert content.find("%s.css" % hash_css) < content.find("site.com/handheld.css")
Exemplo n.º 18
0
def test_chirp_testcase_is_included():
    assert not chirp.is_instrumented()
    chirp.instrument_site(True)

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly('dummyapp/page/chirp.yaml', c)
    content = pa.dumps()

    assert 'dojo.require(\'ChirpTools.TestRunner' in content
    assert 'dojo.require(\'ChirpTools.Mvc' in content
    assert 'ChirpTools.TestRunner.TestCaseCollector' in content
Exemplo n.º 19
0
def test_can_render_lesscss():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/lesscss.yaml", c)

    content = pa.dumps()

    assert '<link rel="stylesheet/less"' in content

    media = (cachedir, "out", "dummyapp", "page", "media")
    css = get_contents(join(*media + ("css", "lesscss.css")))

    assert "@primary: #252525;" in css
    assert "color: @primary;" in css
Exemplo n.º 20
0
def test_creates_files_in_cache():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/sample.yaml", c)

    pa.dumps()

    exist(
        "out/dummyapp/page/media/css/sample.css",
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/notreferenced.js",
        "out/dummyapp/page/media/js/sample.js",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    from skylark import clear_media_cache, copy_addons

    clear_media_cache()
    assert not isdir(join(cachedir, "out"))
    # And fix the addons since we just dumped them
    copy_addons()
Exemplo n.º 21
0
def test_cache_in_debug_mode():
    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly("dummyapp/page/sample.yaml", c)

    tmp = template.loader.get_template("dummyapp/page/media/js/sample.js")
    sample_path = tmp.origin.name
    temp_path = "%s_temp" % sample_path

    pa.dumps()

    exist(
        "out/dummyapp/page/media/css/sample.css",
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/notreferenced.js",
        "out/dummyapp/page/media/js/sample.js",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    content_before = get_contents(join(cachedir, "out", "dummyapp", "page", "media", "js", "sample.js"))

    # Copy to a temp file and alter the original
    shutil.copyfile(sample_path, temp_path)
    sample_fh = open(sample_path, "a")
    sample_fh.write("var changed = true;")
    sample_fh.close()

    pa.dumps()
    content_after = get_contents(join(cachedir, "out", "dummyapp", "page", "media", "js", "sample.js"))

    # Restore the file
    shutil.copyfile(temp_path, sample_path)
    os.remove(temp_path)

    assert content_before != content_after
Exemplo n.º 22
0
def test_bad_html():
    settings.SKYLARK_ENABLE_TIDY = True

    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly("dummyapp/page/badhtml.yaml", c)

    e = py.test.raises(HtmlTidyErrors, pa.dumps)

    assert "line 25" in str(e.value)
    assert "Warning: <tag> missing '>'" in str(e.value)

    settings.SKYLARK_RAISE_HTML_ERRORS = False

    assert pa.dumps()
Exemplo n.º 23
0
def test_can_render_an_asset():
    request = get_request_fixture()
    c = RequestContext(request, {"color": "gray"})
    pa = PageAssembly("dummyapp/page/renderasset.yaml", c)

    content = pa.dumps()

    exist(
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    assert 'my_favorite_color = "gray"' in content
    assert "background-color: gray" in content
Exemplo n.º 24
0
def test_renders_meta_section():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/meta.yaml", c)

    content = pa.dumps()

    exist(
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    assert '<meta http-equiv="test" content="test-content">' in content
    assert '<meta name="test-meta" content="foo">' in content
Exemplo n.º 25
0
def test_deploy_reusable():
    hash_js1 = "96936cfbde05fe1cce209c7f344dbd08"
    hash_js2 = "d921f357906a0e5e06da6a704376247b"
    hash_css = "f27f963509901f608889f688b1e39f72"

    settings.DEBUG = False
    settings.SKYLARK_PLANS = "mediadeploy_reusable"

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js1))
    assert "var static_uses2=null;var static_uses1=null;" in jsfile

    jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js2))
    assert jsfile.find('dojo.provide("dojox.timing._base")') < jsfile.find('dojo.provide("dojox.timing")')
    assert jsfile.find("dojo.provide('PlanApp.Page.View')") < jsfile.find("dojo.provide('PlanApp.Page.Controller')")
    assert jsfile.find("dojo.registerModulePath('ChirpTools'") < jsfile.find("dojo.provide('ChirpTools.Error')")
    assert "dojo.registerModulePath('ChirpTools" not in content

    cssfile = get_contents(os.path.join(cachedir, "out", "%s.css" % hash_css))
    assert ".static_uses2" in cssfile
    assert ".static_uses1" in cssfile
    assert "url(http://localhost:8000/media/" in cssfile
    assert "out/planapp/page/media/img/uses1.gif" in cssfile

    assert "%s.js" % hash_js1 in content
    assert "%s.js" % hash_js2 in content
    assert "planapp/page/media/js/static_uses1.js" not in content
    assert "planapp/page/media/js/static_uses2.js" not in content

    assert "%s.css" % hash_css in content
    assert "planapp/page/media/css/static_uses1.css" not in content
    assert "planapp/page/media/css/static_uses2.css" not in content

    assert content.find("addon/dojo.js") < content.find("%s.js" % hash_js1)
    assert content.find("%s.js" % hash_js1) < content.find("media/uses1.js")

    assert content.find("media/uses1.css") < content.find("%s.css" % hash_css)
    assert content.find("%s.css" % hash_css) < content.find("site.com/handheld.css")

    assert content.find("js/ie7only.css") < content.find("%s.js" % hash_js2)
Exemplo n.º 26
0
def test_will_not_duplicate_assets():
    request = get_request_fixture()
    c = RequestContext(request, {"foo": "bar"})
    pa = PageAssembly("dummyapp/page/duplicateassets.yaml", c)

    content = pa.dumps()

    exist(
        "out/dummyapp/page/media/css/sample.css",
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/notreferenced.js",
        "out/dummyapp/page/media/js/sample.js",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    assert len(re.findall("sample.js", content)) == 1
    assert len(re.findall("files.js", content)) == 1
Exemplo n.º 27
0
def test_will_work_with_templatetags():
    request = get_request_fixture()
    c = RequestContext(request, {})
    pa = PageAssembly("dummyapp/page/tag.yaml", c)

    content = pa.dumps()

    exist(
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
        "out/dummyapp/tag/media/css/screen.css",
        "out/dummyapp/tag/media/img/testimage.png",
        "out/dummyapp/tag/media/js/templates/test.html",
    )

    assert "This is my tag test" in content
    assert '/media/cfcache/out/dummyapp/tag/media/css/screen.css" media="screen"' in content
Exemplo n.º 28
0
def test_deploy_reusable_no_js_minifying():
    hash_js = "d921f357906a0e5e06da6a704376247b"

    settings.SKYLARK_PLANS = "mediadeploy_reusable"

    plan_options(minify_javascript=False)

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js))

    assert "\n        " in jsfile
    assert "//" in jsfile
    # Should be Dojo documentation in here
    assert "// summary:" in jsfile
Exemplo n.º 29
0
def test_deploy_fewest_instrumented():
    hash_js = "cb0aa470231a819d45ee02783f5fc468"

    chirp.instrument_site(True)
    settings.SKYLARK_PLANS = "mediadeploy_fewest"

    request = get_request_fixture()
    c = RequestContext(request)
    pa = PageAssembly("planapp/page/full.yaml", c)

    content = pa.dumps()

    assert "%s.js" % hash_js in content

    jsfile = get_contents(os.path.join(cachedir, "out", "%s.js" % hash_js))

    assert "dojo.provide('chirp')" in jsfile

    chirp.instrument_site(False)
Exemplo n.º 30
0
def test_will_copy_assets():
    request = get_request_fixture()
    c = RequestContext(request, {"title": unicode("Title < > ' \"")})
    pa = PageAssembly("dummyapp/page/sample.yaml", c)

    content = pa.dumps()

    exist(
        "out/dummyapp/page/media/css/sample.css",
        "out/dummyapp/page/media/img/test.png",
        "out/dummyapp/page/media/img/notreferenced.png",
        "out/dummyapp/page/media/js/templates/sample.js",
        "out/dummyapp/page/media/js/notreferenced.js",
        "out/dummyapp/page/media/js/templates/notreferenced.html",
        "out/dummyapp/page/media/js/templates/sample.js",
    )

    assert (
        content.find("notreferenced") == -1
    ), "Found a reference to a file that has been set include: false in the yaml file.  It should not show up in the rendered output"