Example #1
0
 def __init__(self,
              sketch_name,
              interpreter=config.TRANSCRYPT_INTERPRETER,
              **cfg):
     self.sketch_name = sketch_name
     if self.config_file.exists():
         self.config = SketchConfig.from_json(self.config_file)
     else:
         self.config = SketchConfig(interpreter=interpreter, **cfg)
Example #2
0
def test_write_sketch_interpreter_config(custom_index_json_file):
    config = SketchConfig.from_json(custom_index_json_file)
    fd = NamedTemporaryFile(mode="w", delete=False)
    config.write(fd.name)
    fd.close()
    with open(fd.name) as fd:
        data = json.load(fd)

    expected = {
        "interpreter": TRANSCRYPT_INTERPRETER,
        "index_template": str(config.index_template_path.resolve()),
        "p5_js_url": P5_JS_CDN,
    }
    assert data == expected
Example #3
0
def test_get_custom_index_template(custom_index_json_file):
    config = SketchConfig.from_json(custom_index_json_file)
    template = config.get_index_template()
    assert Path(
        "docs/examples/transcrypt/index.html.template").absolute() == template
Example #4
0
def test_init_pyodide_sketch_config_from_json(pyodide_json_file):
    config = SketchConfig.from_json(pyodide_json_file)
    assert config.interpreter == PYODIDE_INTERPRETER
Example #5
0
def test_init_transcrypt_sketch_config_from_json(transcrypt_json_file):
    config = SketchConfig.from_json(transcrypt_json_file)
    assert config.interpreter == TRANSCRYPT_INTERPRETER