def test_no_language_matches(): template = get_test_template() fields = { "body": None, } with pytest.raises(NoLanguageMatches): template.render_first_match(("xx",), fields)
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"]
def test_some_fields_language_fallback(): template = get_test_template() fields = { "body": None } assert template.render_first_match(TEST_TEMPLATE_LANGUAGES, fields)["_language"] == "sw"
def test_no_language_matches(): template = get_test_template() with pytest.raises(NoLanguageMatches): template.render_first_match(("xx", ), ("body", ))
def test_no_language_matches(): template = get_test_template() with pytest.raises(NoLanguageMatches): template.render_first_match(("xx",), ("body",))