def test_js_worker_creation(): manifest = tool.Manifest(plugins=["WorkerPlugin"], search_path=pluginpath) worker_names = [package.name for package in manifest.worker_packages] assert "WorkerPlugin" in worker_names assert "plugin2" in worker_names shared_js = encsio() main_js = encsio() worker_js = encsio() manifest.generate_output_files(shared_js, main_js, worker_js, encsio()) output = shared_js.getvalue() assert "var tiki =" in output assert "WorkerPlugin" not in output assert '"dependencies": {"plugin2": "0.0"}' not in output output = main_js.getvalue() assert "plugin2func" not in output assert "exports.inAWorker" not in output output = worker_js.getvalue() assert '"dependencies": {"plugin2": "0.0"}' in output assert "WorkerPlugin" in output assert """tiki.module("plugin2""" in output
def test_worker_in_manifest(): manifest = tool.Manifest(plugins=["plugin1", "WorkerPlugin"], search_path = pluginpath) errors = manifest.errors plugins = manifest.plugins assert "WorkerPlugin" not in plugins wp = manifest.worker_plugins assert "WorkerPlugin" in wp
def test_full_output(): tmppath = path.getcwd() / "tmp" / "testoutput" manifest = tool.Manifest(plugins=["text_editor"], output_dir=tmppath, include_sample=True) manifest.build() jsfile = tmppath / "BespinEmbedded.js" assert jsfile.exists() samplefile = tmppath / "samples" / "sample.html" assert samplefile.exists()
def test_css_creation(): manifest = tool.Manifest(plugins=["plugin1"], search_path=pluginpath, include_tests=True) output_js = encsio() output_css = encsio() manifest.generate_output_files(output_js, encsio(), encsio(), output_css) output_css = output_css.getvalue() assert "color: white" in output_css assert "background-image: url(resources/plugin1/images/prompt1.png);" in output_css
def test_global_jquery_use(): tmppath = path.getcwd() / "tmp" / "testoutput" manifest = tool.Manifest(plugins=["plugin1"], search_path=pluginpath, jquery="global", output_dir=tmppath) manifest.build() jsfile = tmppath / "BespinEmbedded.js" output = jsfile.text("utf8") assert "exports.$ = window.$;" in output
def test_image_copying(): tmppath = path.getcwd() / "tmp" / "testoutput" manifest = tool.Manifest(plugins=["plugin1"], search_path=pluginpath, include_tests=True, output_dir=tmppath) manifest.build() plugin_image_dir = tmppath / "resources" / "plugin1" / "images" promptfile = plugin_image_dir / "prompt1.png" assert promptfile.exists()
def test_single_file_plugin_handling(): manifest = tool.Manifest(plugins=["SingleFilePlugin1"], search_path=pluginpath, include_tests=True) output = encsio() main_js = encsio() manifest.generate_output_files(output, main_js, encsio(), encsio()) output = main_js.getvalue() assert "exports.someFunction" in output assert "SingleFilePlugin1:index" in output match = find_with_context(output, 'tiki.module("SingleFilePlugin1:../') assert match is None
def test_js_creation(): manifest = tool.Manifest(plugins=["plugin1"], search_path=pluginpath, include_tests=True) shared_js = encsio() main_js = encsio() manifest.generate_output_files(shared_js, main_js, encsio(), encsio()) output = shared_js.getvalue() assert "var tiki =" in output assert "exports.Plugin = function" in output # confirm that boot in not in the shared script assert "bespin.useBespin" not in output # confirm that script2loader is in the shared script assert "importScript" in output output = main_js.getvalue() assert '"dependencies": {"plugin2": "0.0"}' in output assert """tiki.register("::plugin1",""" in output assert """tiki.register("::plugin2",""" in output assert """tiki.module("plugin2:mycode",""" in output assert """exports.plugin2func = function""" in output assert "bespin.useBespin" in output
def test_get_dependencies(): class MockPackage: name = None dependencies = None def __init__(self, name, deps): self.name = name self.dependencies = deps a = MockPackage('a', []) b = MockPackage('b', []) c = MockPackage('c', [ 'a', 'b' ]) d = MockPackage('d', [ 'b' ]) e = MockPackage('e', [ 'd' ]) pkgs = { 'a': a, 'b': b, 'c': c, 'd': d, 'e': e } manifest = tool.Manifest(plugins=list("abcde")) l = manifest.get_dependencies(pkgs, list("abc")) assert l == [a,b,c] or l == [b,a,c] l = manifest.get_dependencies(pkgs, list("bca")) assert l == [a,b,c] or l == [b,a,c] l = manifest.get_dependencies(pkgs, list("ceabd")) assert l == [a,b,c,d,e]