本文整理匯總了Python中flask.get_template_attribute方法的典型用法代碼示例。如果您正苦於以下問題:Python flask.get_template_attribute方法的具體用法?Python flask.get_template_attribute怎麽用?Python flask.get_template_attribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask
的用法示例。
在下文中一共展示了flask.get_template_attribute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_modal_causative
# 需要導入模塊: import flask [as 別名]
# 或者: from flask import get_template_attribute [as 別名]
def test_modal_causative(app, case_obj, institute_obj, variant_obj):
# GIVEN an initialized app
with app.test_client() as client:
# WHILE collection a specific jinja macro
macro = get_template_attribute("variants/utils.html", "modal_causative")
# and passing to it the required parameters
# Including a case without HPO phenotype or diagnosis (OMIM terms) assigned
html = macro(case_obj, institute_obj, variant_obj)
# THEN the macro should contain the expected warning message
assert "Assign at least an OMIM diagnosis or a HPO phenotype term" in html
# WHEN the case contains one or more phenotype terms:
case_obj["phenotype_terms"] = {
"phenotype_id": "HPO:0002637",
"feature": "Cerebral ischemia",
}
# and/or OMIM diagnoses
case_obj["diagnosis_phenotypes"] = [616833]
# THEN the macro should allow to assign partial causatives
html = macro(case_obj, institute_obj, variant_obj)
assert "Assign at least an OMIM diagnosis or a HPO phenotype term" not in html
示例2: test_macros
# 需要導入模塊: import flask [as 別名]
# 或者: from flask import get_template_attribute [as 別名]
def test_macros(self):
app = flask.Flask(__name__)
with app.test_request_context():
macro = flask.get_template_attribute('_macro.html', 'hello')
self.assert_equal(macro('World'), 'Hello World!')
示例3: test_modal_prompt_filter_name
# 需要導入模塊: import flask [as 別名]
# 或者: from flask import get_template_attribute [as 別名]
def test_modal_prompt_filter_name(app):
# GIVEN an initialized app
with app.test_client() as client:
# WHILE collection a specific jinja macro
macro = get_template_attribute("variants/utils.html", "modal_prompt_filter_name")
# and passing to it the required parameters
# Including a case without HPO phenotype or diagnosis (OMIM terms) assigned
form = FiltersForm()
html = macro(form)
# THEN a string from the modal can be found in the output
assert "Please name" in html
示例4: test_update_individuals_table
# 需要導入模塊: import flask [as 別名]
# 或者: from flask import get_template_attribute [as 別名]
def test_update_individuals_table(app, case_obj, institute_obj):
# GIVEN an initialized app
with app.test_client() as client:
# WHEN collecting the individuals_table jinja macro
macro = get_template_attribute("cases/individuals_table.html", "individuals_table")
# and passing to it the required parameters
html = macro(case_obj, institute_obj, SAMPLE_SOURCE)
# THEN the macro should contain the expected html code
assert '<div class="panel-heading">Individuals</div>' in html
示例5: query_result
# 需要導入模塊: import flask [as 別名]
# 或者: from flask import get_template_attribute [as 別名]
def query_result():
"""Render a query result to HTML."""
query = request.args.get("query_string", "")
table = get_template_attribute("_query_table.html", "querytable")
contents, types, rows = g.ledger.query_shell.execute_query(query)
if contents:
if "ERROR" in contents:
raise FavaAPIException(contents)
table = table(contents, types, rows)
if types and g.ledger.charts.can_plot_query(types):
return {
"table": table,
"chart": g.ledger.charts.query(types, rows),
}
return {"table": table}