Python flask.get_template_attribute() Examples

The following are 13 code examples of flask.get_template_attribute(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module flask , or try the search function .
Example #1
Source File: test_variants_utils.py    From scout with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #2
Source File: templating.py    From Flask-P2P with MIT License 5 votes vote down vote up
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!') 
Example #3
Source File: test_variants_utils.py    From scout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #4
Source File: test_cases_utils.py    From scout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #5
Source File: json_api.py    From fava with MIT License 5 votes vote down vote up
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} 
Example #6
Source File: templating.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
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!') 
Example #7
Source File: templating.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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!') 
Example #8
Source File: templating.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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!') 
Example #9
Source File: templating.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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!') 
Example #10
Source File: templating.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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!') 
Example #11
Source File: templating.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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!') 
Example #12
Source File: templating.py    From Flask with Apache License 2.0 5 votes vote down vote up
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!') 
Example #13
Source File: templating.py    From Flask with Apache License 2.0 5 votes vote down vote up
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!')