Example #1
0
def test_no_language_matches():
    template = get_test_template()
    fields = {
        "body": None,
    }
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), fields)
Example #2
0
def test_no_language_matches():
    template = get_test_template()
    fields = {
        "body": None,
    }
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), fields)
Example #3
0
def test_template_render(template=None):
    template = get_test_template()
    # since both subject and body are required, "sw" is disqualified
    japanese_render = template.render_first_match(TEST_TEMPLATE_LANGUAGES, ("subject", "body"))
    assert japanese_render["_language"] == "ja"
    # test that |upper worked
    assert template.context.get("name").upper() in japanese_render["body"]
Example #4
0
def test_template_render(template=None):
    template = get_test_template()
    # since both subject and body are required, "sw" is disqualified
    japanese_render = template.render_first_match(TEST_TEMPLATE_LANGUAGES, ("subject", "body"))
    assert japanese_render["_language"] == "ja"
    # test that |upper worked
    assert template.context.get("name").upper() in japanese_render["body"]
Example #5
0
def test_some_fields_language_fallback():
    template = get_test_template()
    fields = {
        "body": None
    }
    assert template.render_first_match(TEST_TEMPLATE_LANGUAGES, fields)["_language"] == "sw"
Example #6
0
def test_no_language_matches():
    template = get_test_template()
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx", ), ("body", ))
Example #7
0
def test_some_fields_language_fallback():
    template = get_test_template()
    fields = {
        "body": None
    }
    assert template.render_first_match(TEST_TEMPLATE_LANGUAGES, fields)["_language"] == "sw"
Example #8
0
def test_no_language_matches():
    template = get_test_template()
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), ("body",))