def test_all_templates(): project_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) app_templates_folder = os.path.join( os.path.join(project_dir, "templates"), "apps") abs_template_folder = os.path.split(app_templates_folder)[0] for root, dirs, files in os.walk(app_templates_folder): rel_dir = root[len(abs_template_folder)+1:] for name in files: template_name = os.path.join(rel_dir, name) if template_name.endswith("tmpl"): try: print template_name tr = render_template.render_template(template_name, {}) t = json.loads(tr) print json.dumps(t, indent=2) except Exception as e: assert False, "%s: %s" % (template_name, e)
def test_all_templates(): project_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) app_templates_folder = os.path.join(os.path.join(project_dir, "templates"), "apps") abs_template_folder = os.path.split(app_templates_folder)[0] for root, dirs, files in os.walk(app_templates_folder): rel_dir = root[len(abs_template_folder) + 1:] for name in files: template_name = os.path.join(rel_dir, name) if template_name.endswith("tmpl"): try: print template_name tr = render_template.render_template(template_name, {}) t = json.loads(tr) print json.dumps(t, indent=2) except Exception as e: assert False, "%s: %s" % (template_name, e)
def test_basic_render(): context = {"instances": 1} tmpl_res = render_template.render_template( "apps/tests/test_basic.json.tmpl", context) data = json.loads(tmpl_res) assert int(data["instances"]) == 1
def load_tempate(name, context): return render_template(name, context)
def test_include(): tmpl_res = render_template.render_template( "apps/tests/test_docker.json.tmpl", {}) print tmpl_res data = json.loads(tmpl_res) assert len(data["healthChecks"]) == 1