예제 #1
0
def test_no_language_matches():
    template = get_test_template()
    fields = {
        "body": None,
    }
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), fields)
예제 #2
0
def test_no_language_matches():
    template = get_test_template()
    fields = {
        "body": None,
    }
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), fields)
예제 #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"]
예제 #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"]
예제 #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"
예제 #6
0
def test_no_language_matches():
    template = get_test_template()
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx", ), ("body", ))
예제 #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"
예제 #8
0
def test_no_language_matches():
    template = get_test_template()
    with pytest.raises(NoLanguageMatches):
        template.render_first_match(("xx",), ("body",))